我在这里做错了什么?我正在尝试使用 javascript 运行一小段验证 bny。我正确地做正则表达式吗?
var z=document.forms["myForm"]["website"].value;
if (z==null || z=="")
{
$('.five').show();
return false;
}
var validWebsite = /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/
if(!validWebsite.test(document.forms["myForm"]["website"].value))
{
$('.five').html('Enter a Valid Website');
return false;
}
var number = /^(\()?\d{3}(\))?(-|\s)?\d{3}(-|\s)\d{4}$/
if(!number.test(document.forms["myForm"]["number"].value)){
$('.six').show()
return false;
}
html
*email: <br>
<input type="text" name="email"/><div class="four alertmessage" style="display:none;color:red;">Enter your Email</div><br>
website: <br>
<input type="text" name="website"/><div class="five alertmessage" style="display:none;color:red;">Enter your Website</div><br>
Contact phone number: <br>
<input type="text" name="number"/><div class="six alertmessage" style="display:none;color:red;">Enter your Number</div>
<input name="submit" class="submitButton" type="submit" value="Submit">