[英]Why dont I get the alert message when i click the sign up button?
When i click the Sign up button, I dont get the alert message.当我单击“注册”按钮时,我没有收到警报消息。 Other alerts show the output perfectly.
其他警报完美地显示了输出。 But I think there is problem in the else statement.
但我认为 else 语句中存在问题。 I want to show the alert message when any user click the Sign up button.
我想在任何用户单击“注册”按钮时显示警报消息。
function check(form) {
name = form.name.value;
mobile = form.mobile.value;
age = form.age.value;
email = form.email.value;
password = form.password.value;
conpassword = form.conpassword.value;
if(name==''){
swal({
title: "Empty Field!",
text: "Enter Name",
icon: "warning",
});
return false;
}
else if(mobile==''){
swal({
title: "Empty Field!",
text: "Enter Mobile Number",
icon: "warning",
});
return false;
}
else if(age==''){
swal({
title: "Empty Field!",
text: "Enter Age",
icon: "warning",
});
return false;
}
else if(email==''){
swal({
title: "Empty Field!",
text: "Enter E-mail",
icon: "warning",
});
return false;
}
else if(password==''){
swal({
title: "Empty Field!",
text: "Enter Password",
icon: "warning",
});
return false;
}
else if(conpassword==''){
swal({
title: "Empty Field!",
text: "Enter Confirm Password",
icon: "warning",
});
return false;
}
else if(password!=conpassword){
swal({
title: "",ant
text: "Password Did Not Match",
icon: "error",
});
return false;
}
else{
swal({
title: "Thank You!",
text: "Now you can access",
icon: "success",
});
return true;
}
}
I use SweetAlert ( swal()
)我使用SweetAlert (
swal()
)
in your html one is wrong and in在你的 html 中,一个是错误的,在
javascript ,ant after title is cause error javascript,标题后的蚂蚁是导致错误的原因
else if(password!=conpassword){
swal({
title: "",ant/*wrong*/
text: "Password Did Not Match",
icon: "error",
});
return false;
}
function check(form) { name = form.name.value; mobile = form.mobile.value; age = form.age.value; email = form.email.value; password = form.password.value; conpassword = form.conpassword.value; if(name==''){ swal({ title: "Empty Field!", text: "Enter Name", icon: "warning", }); return false; } else if(mobile==''){ swal({ title: "Empty Field!", text: "Enter Mobile Number", icon: "warning", }); return false; } else if(age==''){ swal({ title: "Empty Field!", text: "Enter Age", icon: "warning", }); return false; } else if(email==''){ swal({ title: "Empty Field!", text: "Enter E-mail", icon: "warning", }); return false; } else if(password==''){ swal({ title: "Empty Field!", text: "Enter Password", icon: "warning", }); return false; } else if(conpassword==''){ swal({ title: "Empty Field!", text: "Enter Confirm Password", icon: "warning", }); return false; } else if(password!=conpassword){ swal({ title: "Empty Field", text: "Password Did Not Match", icon: "error", }); return false; } else{ swal({ title: "Thank You!", text: "Now you can access", icon: "success", }); return true; } }
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script> <form onsubmit="return check(this)" action="#" method="post"> <input type="text" name="name" > <input type="text" name="mobile"> <input type="text" name="age" > <input type="text" name="email" > <input type="password" name="password"> <input type="password" name="conpassword" > <input type="submit" value="Sign Up"> <a href="#">Forget Password</a> </form>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.