html - jquery highlight input boxes when credentials are wrong when logging in to website -
i'm not sure why can't function correctly in jsfiddle:
perhaps it's because post action directing page? maybe it's working because of url change i'm not seeing it?
<script> $('#loginform').submit(function(){ var vals = $('.nomargin').val() if (!vals) { console.log('error exists'); $('.nomargin').attr('style', "border-radius: 5px; border:#ff0000 1px solid;"); $('.nomargin').val('enter value'); } return false; }); </script> <div class="loginbox clearmefocus"> <form action="client_homepage.dhtml" method="post" name="loginform" id="loginform" > <input type="hidden" name="site" id="site" value="free"> <h3>agent log in</h3> <div style="float: left; font-size: 10px; color: red; margin-top: -8px; position: absolute;"></div> <div class="clearfix"> <input type="text" name="username" id="username" value="" title="username" class="nomargin"> <input type="password" name="password" id="password" value="" title="password"> <input type="image" src="images/submit.png" value="submit" name="submit" id="submit" alt="submit"> </div> <h6><a href="/join.dhtml">not associate?</a> <a href="/password.html">forgot password?</a></h6> </form> </div> any appreciated. thank you.
you returning false outside condition, form never submitted, update follows:
$('#loginform').submit(function(){ var vals = $('.nomargin').val() if (!vals || vals=="") { console.log('error exists'); $('.nomargin').attr('style', "border-radius: 5px; border:#ff0000 1px solid;"); $('.nomargin').val('enter value'); return false; } }); check fiddle
Comments
Post a Comment