Search code examples
jqueryformstwitter-bootstrapemail-validation

Form and required email type for input


When I create a form with required input:

<form action="" id="FormMessage"  method="post" >
    <div style="max-width:700px;">
                    <input name="InputEmail" id="InputName" class="email" type="text" width="100%" placeholder="Your email" required>
            <div style="padding-top:20px">
                <button id="BtMessage" class="btn btn-primary">Send</button>
            </div>
    </div>
 </form>

If it's not filled we get this Warning message:

enter image description here

Example when trying to click on Send button without having filled The Email: http://jsfiddle.net/c9b47j9j/

Is there any way to get this same message but if what has been filled is not an email ?


Solution

  • Then you need to change input type="text" to type="email". Then it will autovalidate the field as EMAIL. But remember this is just HTML 5 validation.

    If you want to use some more additional validation you need to use JS OR jQuery pulgins, or write it yourself. Some jQuery form validation plugin links below::