0

HTML:

<form id="myform"  method="post">
    <input name="email"  type="email" required=""/>
    <input name="fname" type="text" required="" />
    <input name="zip" type="text" />
    <input  type="button" value="button" />
</form>

Here I want to just check email by applying javascript function for html5 can we do that?

Edit
It has been unclear/misunderstood before. My question is do we have boolean valid check like form.email.valid() so that we can do check for email only with using javascript?

vusan
  • 5,221
  • 4
  • 46
  • 81

1 Answers1

2

You should change your button input. A HTML5 submit button needs to look like the following:

<button type="submit">Submit</button>

Also, giving your e-mail a placeholder would be nice:

<input name="email" type="email" placeholder="me@example.com" required=""/>

Example jsFiddle.

dsgriffin
  • 66,495
  • 17
  • 137
  • 137
  • I need to call by not submitting the form or I may need to check the validity of just email . – vusan Mar 29 '13 at 10:01
  • @vusan Have you tried the jsFiddle? it already validates whether it's an e-mail or not – dsgriffin Mar 29 '13 at 10:03
  • 1
    ok now can we use like `$('#form')[0].checkValidity()` with pure javascript. – vusan Mar 29 '13 at 10:19
  • Check this [link](http://stackoverflow.com/questions/5688122/html5-form-validation-void-form-action-and-execute-jquery-when-all-html5-form-e) has a accepted answer, to the "same" question, just submit and preventDefaults. – winner_joiner Mar 29 '13 at 10:21
  • @vusan Yep! check out the link that winner_joiner posted for that – dsgriffin Mar 29 '13 at 10:25