为什么警告框弹出,即使我输入正确数量的字符串/数据
why is alert box popping out even if I input correct amount of strings/data?
我的用户名var验证有问题吗?,我不知道为什么警报框一直弹出,即使我提供了正确的用户名数据:(
if(userid == ""){
$( "#dialog:ui-dialog" ).dialog( "destroy" );
$( "#dialog-confirm" ).dialog({
resizable: false,
height: 230,
width: 350,
modal: true,
buttons: {
"Register": function(){
$(this).dialog("close");
$('div#registerpopup').dialog({
resizable: false,
height: 485,
width: 420,
modal: true,
buttons: {
"Register": function(){
if(username == "" || username.length < 1 || username.length > 30 || username.indexOf(' ') != -1){
alert("Username is required'n-should not be less than 1 character'n-not greater than 30 characters'n-It may also not contain spaces");
return false;
}
if(password.length < 7 || password.indexOf(' ') != -1 ){
alert("Password should not be empty'n-should at least be 7 characters");
return false;
}
if(retypepassword != password){
alert("re-type password should be the same as the password!");
return false;
}
if(emailaddress == "" || emailaddress.search(emailRegEx) == -1){
alert("Email Address is required and should be a valid email address");
return false;
}
if(secondaryemailaddress != emailaddress){
alert("Secondary Email address should be the same as the primary email address!");
return false;
}
if(secretquestion == ""){
alert("Secret Question is required!");
return false;
}
if(secretanswer == ""){
alert("Secret Answer is required!");
return false;
}
if(reffcode == ""){
alert("Reference Code is required!");
return false;
}
$(this).dialog("close");
}
}
});
},
"Log in": function() {
$(this).dialog("close");
$('div#loginpopup').dialog({
resizable: false,
height: 230,
width: 350,
modal: true
})
}
}
});
return false;
}
验证的逻辑是好的,我猜你会丢失或重置用户名值在同一点或不设置它。
将autoOpen: false
添加到jQuery UI对话框中。
$('div#loginpopup').dialog({
autoOpen: false,
resizable: false,
height: 230,
width: 350,
modal: true
});
相关文章:
- Ajax请求返回空的数据字符串,但首先得到了正确的数据
- Javascript / JQuery循环访问已发布的ajax数据字符串以为其分配新值
- 保存Canvas图像(将数据字符串发布到PHP)
- 如何将数据字符串附加到角度$http
- Mozilla Persona 符号数据字符串
- JSON 数据字符串替换和日期格式
- Javascript 字典到 html 数据字符串
- 如何在服务器端保存PNG图像,使用base64数据字符串javascript
- 访问javascript中的json数据(字符串数组)
- 基于浏览器的本地文件系统到SVG base64数据字符串
- 为什么这个ajax请求有一个数据字符串,里面有一堆带破折号的数字
- 字符串化字符串化的数据字符串
- 分割数据-字符串.分离参数
- 如何在三星Note 2上使用toDataURL创建JPG数据字符串
- 使用javascript删除特定的数据字符串
- 无法在d3.js中对有序数据(字符串)执行刷刷
- 将数据字符串转换为对象
- 正确解码Get Blob数据字符串到ArrayBuffer
- 在服务器端保存画布图像时,从base64数据字符串生成空白图像
- 如何预防'未定义'从流中读取数据时的数据字符串