我有一个登录页面。当用户点击登录按钮时,会弹出“条款和条件”对话框,但如果用户名和密码不正确,会弹出“无效”对话框。但问题是当输入错误的细节时,首先弹出“条款和条件”对话框,然后只有在单击对话框后才显示“无效”对话框。我需要在无效的条目之前弹出无效的对话框。条款和条件对话。你可以告诉我在我的代码中做错了什么吗?
onClick: function (event) {
if (event)
event.preventDefault();
if ($(event.currentTarget).attr('id') == "btnLogin") {
$('#txtLogin').val($('#username').val());
$('#txtPassword').val($('#password').val())
}
if (($('#txtLogin').val() === "") || ($('#txtPassword').val() === "") || ($('#txtLogin').val() === "Number") || ($('#txtPassword').val() === "Password")) {
if ($(event.currentTarget).attr('id') == "btnLogin") {
$('#dismiss').click();
}
$("<div>Please enter user name and password</div>").dialog({
position: 'top',
modal: true,
resizable: false,
title: "Error",
buttons: { "Okay": function () { $(this).dialog("close"); } }
});
return;
}
CheckLogon($('#txtLogin').val(), $('#txtPassword').val(),checkLogonSuccess, onError); //checklogonSuccess calls terms and conditions and on error calls invalid details.i tried adding it as this CheckLogon($('#txtLogin').val(), $('#txtPassword').val(), onError,checkLogonSuccess,); but it doesnt do anything.
},
onError: function (ex) {
$('#btnLogin').show();
$("<div>" + ex._message +"</div>").dialog({
position: 'top',
modal: true,
resizable: false,
title: "Error",
buttons: { "Okay": function () { $(this).dialog("close"); } }
});
}
TermsSuccess: function (result, context) {
var topTerms = findSetByInArray(result.Data, 'ParentId', 0);
var termsHTML = '<div id="terms"><ul class="termsList">';
for (var i = 0; i < topTerms.length; i++) {
var cls = (topTerms[i].isNew) ? 'newTerm' : 'Term';
termsHTML += '<li id=' + topTerms[i].ID + ' class=' + cls + '>'
termsHTML += topTerms[i].PageIndex + '. ' + topTerms[i].Detail;
termsHTML += betMethods.getChildrenTerms(result.Data, topTerms[i].ID, topTerms[i].PageIndex + '. ');
termsHTML += '</li>';
}
termsHTML += '</ul></div>';
$('#dismiss').click();
$(termsHTML).dialog({
modal: true,
resizable: false,
width: 600,
height: 600,
closeOnEscape: false,
open: function (event, ui) {
$(this).parent().children().children('.ui-dialog-titlebar-close').hide();
},
title: "Terms & Conditions",
buttons: [{
text: "Decline",
"class": 'btnDialog',
click: function () {
$(this).dialog("close");
}
},
{
text: "Accept",
"class": 'btnDialog',
click: function () {
betEvents.btnAccept_onClick();
$(this).dialog("close");
}
}]
});
},
checkLogonSuccess: function (result, context) {
GetTerms(result,TermsSuccess, onError);
},
CheckLogon(string account, string password)
{
Stopwatch stopwatch = Stopwatch.StartNew();
DateTime? result = null;
var aNumber = number;
if (Context.Enabled)
{
var profile = Context.Current.ValidateLogin(account, password);
if (profile == null)
throw new SecurityException("Invalid username / password");
var key = profile._UserID.ToString();
var mapping = DependencyResolver.GetService<DataContext>().AccountUserNameMappings.FirstOrDefault(x => x.Key == key);
if (mapping == null)
aNumber = null;
else
aNumber = mapping.ANumber;
}
}
答案 0 :(得分:0)
CheckLogon正在等待2个参数,你给它4个。