javascript
html验证邮箱自动,html5+JavaScript进行邮箱地址验证
body, input, textarea {
font-family: "helvetica", arial, helvetica;
}
label {
display: block;
float: left;
clear: left;
text-align: right;
width: 100px;
margin-right: 10px;
}
p { padding: 10px; }
fieldset { border: 1px solid #ccc; margin-bottom: 20px; }
some bits about you
email:
homepage:
// default validation messages
var messages = {
email: 'be not a legal email address',
url: 'be not a valid web address',
comment: 'ye have to specify ye value'
};
var forms = document.getelementsbytagname('form'), i = forms.length, j, el;
while (i--) {
j = forms[i].length;
while (j--, el = forms[i][j]) {
if (el.willvalidate && messages[el.name]) {
el.setcustomvalidity(messages[el.name]);
}
}
}
var form = document.getelementsbytagname('form')[0];
form.onsubmit = function (event) {
var i = this.length, el, cont = true, errors = [];
while (i--, el = this[i]) {
if (el.willvalidate) {
if (!el.validity.valid) {
errors.push('error with ' + el.name + (el.validationmessage ? ': ' + el.validationmessage: ''));
cont = false;
}
}
}
if (errors.length) {
// replace alert with your sexy css教程 info bubbles
alert(errors.join('n'));
}
return cont;
};
總結(jié)
以上是生活随笔為你收集整理的html验证邮箱自动,html5+JavaScript进行邮箱地址验证的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ehRecvr.exe进程安全吗 ehR
- 下一篇: 《雷神4》新预告发布!微软推出雷神之锤定