不是所有的故事都能成为你的眼睛里的色彩,因为岁月会淡化你的颜色。当你的人生路走得不平顺的时候,不要忘记了,你只是走过这条路而已,走过以后一切只能任时光处置。
Try testing the following form with valid and invalid email addresses. The code uses javascript to match the users input with a regular expression.
函数代码:
function validate(form_id,email) {
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
var address = document.forms[form_id].elements[email].value;
if(reg.test(address) == false) {
alert('Invalid Email Address');
return false;
}
}
In the forms ‘onsubmit' code call javascript:return validate(‘form_id','email_field_id')
使用方法:
<form id="form_id" method="post" action="action.php" onsubmit="javascript:return validate('form_id','email');">
<input type="text" id="email" name="email" />
<input type="submit" value="Submit" />
</form>
You should not rely purely on client side validation on your website / web application, if the user has javascript disabled this will not work. Always validate on the server.
from: http://www.white-hat-web-design.co.uk/blog/javascript-validation/
到此这篇关于Javascript Validation for email(正则表达式) 英文翻译就介绍到这了。如果我想做成一件事,那么无论需要多长时间我都会努力去挤。更多相关Javascript Validation for email(正则表达式) 英文翻译内容请查看相关栏目,小编编辑不易,再次感谢大家的支持!