[英]Can't get alert to not show if value is correct
I am trying to get the following form submission to show alert box if value is not equal to 'Province" 我尝试获取以下表单提交以在值不等于“省”的情况下显示警告框
function validate_form ( )
{
if ( document.contactForm.Province!='Region 1' )
alert ( "Please Note: We only install in Region 1!" );
}
My form name is "contactForm" my select menu is called "Province" I always get the alert here regardless of the selection in Province. 我的表单名称为“ contactForm”,我的选择菜单称为“省”。无论在省份中进行选择如何,我总是在这里收到警报。
What am I doing wrong? 我究竟做错了什么?
您需要将其与该元素的值进行比较:
if ( document.contactForm.Province.value != 'Region 1' )
Try this 尝试这个
function validate_form ( )
{
var temp = document.getElementbyId(Province);
var strUser = temp.options[e.selectedIndex].text;
if (strUser != 'Region 1' )
alert ( "Please Note: We only install in Region 1!" );
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.