我正在进行表单验证,要求是 1.Email:电子邮件必须是有效的电子邮件 ID。2.密码:必须是八个字符长。只允许使用数字 (0-9) 和字母 (AZ,az)。3.FirstName:不能包含任何数字(0-9)。4.LastName :不能包含任何数字(0-9)。我为电子邮件地址做了,我对密码和名字验证感到震惊.. 任何人都可以帮助我提前致谢。
<form>
<label for="">First Name</label>
<input type="text" id="fname"><br>
<label for="">Last Name</label>
<input type="text" id="lname"><br>
<label for="">Email</label>
<input type="text" id="email"><br>
<label for="">Password</label>
<input type="text" id="password"><br>
<button type="button" onclick="claim()">Claim Your Free Trail</button>
<p>You Are Agreeing to Our <a href="#">Terms & Condition</a></p>
</form>
<script>
function claim(){
var obj ={
fname:"",
lname:"",
email:"",
password:""
}
for(a in obj){
obj[a]=document.getElementById(a).value
}
if(obj.email.match(/@/) != null){
}else{
alert("Please enter Valid Email Address")
}
console.log(obj)
}
</script>
</body>