javascript - Using Validation on Jquery pop up login menu -
i have jquery pop menu using bootstrap . has validation issues when password field empty or password wrong ,i tried couple of ways . works when type in password or username field , still stays there here codes
<div class="container"> <h4>demo page</h4> <!-- twitter content --> <div id="form-content" class="modal hide fade in"> <a class="close" data-dismiss="modal">×</a> <div> <form class="contact" action=""> <div class="modal-body"> <ul class="nav nav-list"> <li class="nav-header">username</li> <li> <input class="input-xlarge" type="text" id="txtusername" name="username"> </li> <li class="nav-header">password</li> <li> <input class="input-xlarge" type="text" id="txtpassword" name="password"> </li> </ul> </div> </form> </div> <div class="modal-footer"> <%--<input type="button" value="sign up" id="btnlogin" />--%> <button class="btn btn-success" id="btnlogin"> sign </button> <a href="#" class="btn" data-dismiss="modal">close</a> </div> <div id="dialog" title="message"> </div> </div> </div>
and js file has function
function getuserinfo() { var username = document.getelementbyid('txtusername').value; var password = document.getelementbyid('txtpassword').value; if (username == "") { $('#dialog').text("please type username."); return false; } else if (password == "") { $('#dialog').text("please type password."); return false; } $.ajax({ url: "webservices/prodmonitorservice.asmx/validateuser", data: "{'username':'" + username + "','password':'" + password + "'}", datatype: "json", type: "post", contenttype: "application/json; charset=utf-8", async: true, success: function (data) { var obj = jquery.parsejson(data.d); try { if (obj.length == 1) { $("#dialog").dialog("close"); } else { $('#dialog').text(result.d.message); $("#dialog").dialog("open"); } } }); }
i want display error message when username or password not match and/or blank . use 1 <div id="dialog" title="message">
display error messages based on condition. issue , error message not going away when correct it
any appreciate..
use following code in beginning of getuserinfo function.
$('#dialog').text(""); $("#dialog").dialog("close");
for validating username , password, can achieve service side , return status , message success result.
hope helps.
thanks
Comments
Post a Comment