Hi All,

I have a simple form that I want to send me an email when the button is clicked. I have two questions,
1. How can I make the fields Name and Email mandatory?
2. It does not send an email to me when used with my smartphone, which is an Android.
The code:

<form action="MAILTO:michaelmvasas@shaw.ca?subject=LC"> <br> <input type="text" name="name" value="Your Name"> <br> <br> <input type="text" name="mail" value="Your Best Email"><br> <br><br> <input type="submit" value="Submit"> </form> 

Also, you can see I have a value for each field, however, I'd rather have the fields empty and have those values just above the fields.
One last question, does the value for the submit button have to match the value that's on the button? In the code it says "Submit" but on the form itself it says Give Me Information.

Any and all help will be very much appreciated. :)

PS, This does work on my computer but for some reason the body in the email contains a long string value that I do not want there. Any idea about that?

Hey Stuugi, I have an awnser to your problem;

Name: <input type="text" name="name" required>
Email address: <input type="email" name="email" required placeholder="enter valid email address ">

commented: Thanks, I appreciate part of teh answer +7

You will need to add the 'label' element to your inputs aswell.

<form>

    <div>

        <label for="name">Name</label>
        <input type="text" name="name" placeholder="Your Name" required>

    </div>

    <div>

        <label for="email">Email</label>
        <input type="email" name="email" placeholder="enter valid email address" required>

    </div>

</form>

And set your label and input to display: block in your CSS, so that they will stack ontop of each other.

commented: Thanks, this is very helpful +7

I just read that this type of form can only be run on IE, which is not very ideal.

Member Avatar for diafol

Never understood the need for this. Do you not a server-side language like PHP or similar?

@Diafol, I am using a WordPress plugin called WP Optin so yes. However, I have (admittedly) not much experience with PHP.

I had to remove my version of the WP Optin because they were too buggy and I don't want buggy on my site.

Member Avatar for diafol

Ok. Many email forms scripts available in PHP. Targeting a single browser is as bad as buggy though :)

commented: I agree, thanks +7

So, I've decided to emerge myself in PHP so that I can get more functionality out of my WordPress site. Thanks Diafol for this nudge, I think it has been long overdue.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.