javascript - Multiple case validation using jquery validation plugin -


i have created following login form in html , validation has been done using jquery validate plugin. http://jqueryvalidation.org/ here , validating whole login form when login button clicked.

    <form method="post" id="loginform">         <label>email</label>         <input type="text" id="user_email" name="user_email" />         <br>         <label>password</label>         <input type="password" id="user_pass" name="user_pass" />         <br>         <input type="button" value="login" id="btnlogin">     </form> 

validation script

$("#loginform").validate({     rules: {         user_email: {             required: true,             email: true         },         user_pass: {             required: true         }     },     messages: {         user_email: {             required: "email required",             email: "enter valid email address"         },         user_pass: {             required: "password required"         }     } }); $('#btnlogin').click(function() {     var form = $('#loginform');     if (form.valid()) {         // submit form data     } }); 

like validating whole form error labels when button clicked , want validate email field without error labels , error classes case. when user entering email address want validate validity of email address(true or false) without validating whole form , without displaying error label.just validity. how achieve using jquery validation plugin. tried jquery input text change event, not work.

$('#user_email').on('input',function(){     //check valid email address on text change of email input }) 

please me in this. thank you.

add

$( "#user_email" ).focusout(function() {   var re    = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-za-z\-0-9]+\.)+[a-za-z]{2,}))$/;   var email = $("#user_email").val();   if(!re.test(email)) {       //give proper valodation message here       alert("invalid email...!!");       $("#user_email").focus();       } }); 

this show alert message when invalid email addess given andd pass next next field , cursor in email field

edit

as per comment validation http://jqueryvalidation.org/ 1 single field (email) shown below.

  $('#btnlogin').click(function() {         if($("#loginform").validate().element($("#user_email"))){         //give proper valodation message here         alert("invalid email..!!");         }     }); 

enjoy coding... :)


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -