Submit button won't submit....
Answered
- Need more info
- Working on it
- Answered
in Getting Started
•
11 years ago
Hi,
I copied codes on internet and arranged them according to my knowledge of JQuery (which is very shallow).. The code works fine sometimes.... but not all the time. Can anyone help me to find out why the dialog box does not appear everytime I put wrong username and password?
Here is the JQuery code:
$(document).ready(function () {
$("input:submit", ".login").click(function () {
var username = $('#txt_username').val();
var acctid = $('#txt_accountid').val();
var pwd = $('#txt_password').val();
$.ajax({
type: 'POST',
url: 'login.aspx/LoginValidation',
data: '{"iAcctID":"' + acctid + '", "iPwd":"' + pwd + '", "iUserName":' + username + '}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
var iMsg = '';
alert('ok');
switch (msg.d) {
case -1: iMsg = 'Wrong user name and password';
break;
default: iMsg = 'Other errors.';
break;
};
if (iResult < 1) {
var myDialog = $(document.createElement('div'));
$(myDialog).html(iMsg);
$(myDialog).dialog({
modal: true,
autoOpen: false,
title: 'Information',
show: 'slidedown',
buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
}
});
$(myDialog).dialog('open');
};
if (iResult == 1) {
window.location.replace("www.google.com");
};
}
});
event.preventDefault();
});
});
At HTML, I have the following...
<td class="style41">
<div class="login">
<input type="submit" ID="but_Submit"
class="ui-button ui-button-text-only ui-widget ui-state-default ui-corner-all"
style="font-family:Arial; font-size:medium; top: 0px; left: 0px; width: 142px;"
value="Login" />
</div>
</td>
Because I am using ui-darkness as the page theme, so at form tag, I don't have defaultbutton="but_submit" tag. If I add it back, I will get error while compiling..
Thanks for help..
Stephany Lin
1