asp.net - jquery validation is not working properly -
i new jquery.
by googling have done following code not working.
i have txtlogin textbox , btnlogin button.
i trying simple thing. if textbox expty error message should displayed in lblloginerror.
following code:
$(document).ready(function () { $('#btnlogin').click(function () { var loginid = $("#txtlogin").val(); if ($("#txtlogin").val() == "") { $("#lblloginerror").text("please enter login id"); return false; } else { $("#lblloginerror").text(""); return true; } }); }); my problem is>> first time when textbox empty , click on button gives me error message on lable[its working fine according code].
second time when enters thing in textbox , press button removing error message.[this fine according code].
but third time when removes entered text , presses button , not shows me error message.
*note: using .net in ajax update panel. page not gets refreshed each time. can problem?
it useful link jquery validation
example:
<script> $(document).ready(function(){ $("#commentform").validate(); }); </script> <form id="commentform"> <input type="text" id="txtlogin" class="required"/> <input class="submit" type="submit" value="submit"/> </form> here can apply class required.
Comments
Post a Comment