jquery - paste email to input and validation right away. -
function checkemail(){ // set variable var email_target = $("#signupmenu-emailinput"); var email_value = email_target.val(); var email_errorspan = $("#email-errorresult"); var emailpass_boolean; if(email_value === ""){ // email empty email_errorspan.html("please enter email."); email_errorspan.css("color", "red"); email_target.css("border-color", "red"); }else if(email_value > 0){ email_errorspan.html("pass."); email_errorspan.css("color", "red"); email_target.css("border-color", "red"); } } $(document).ready(function(){ // singup email input $("#signupmenu-emailinput").bind({ keyup : function(){ checkemail(); }, paste : function(){ checkemail(); } }); });
my intention validation went user copy past on input , validation right away , somehow if paste , ask me enter email email should ok , should text out pass.
see demo understand more.
how did make input check , validation after paste ? demo here
your validation wrong, you're checking numeric value inside field doing
if(email_value > 0)
change to
if(email_value.length > 0)
Comments
Post a Comment