【发布时间】:2025-12-06 23:20:04
【问题描述】:
我想添加一个 javascript 来检查并阻止我的表单在其他用户提供已被其他人使用的电子邮件地址时自行提交。 我知道这不是一种专业的方法,但我需要这个解决方案来完成一个简单的项目。
以下是我自己尝试过但无法正常工作的 javascript。
function check(form) /*function to check used email addresses*/ {
/*the following code checkes whether the entered email address is used*/
if (form.usercheck1.value == "sttf@gmail.com"
|| form.usercheck1.value == "dandy@gmail.com")
{
alert("The email address you provided has been used by another user."));
return false;
}
return true;
}
<form action='' method='POST' onsubmit="return check_usercheck1();"></form>
<input name='email' id="usercheck1" placeholder='email' required='' type='email'/>
【问题讨论】:
标签: javascript forms validation