基本注册表单验证
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基本注册表单验证相关的知识,希望对你有一定的参考价值。
I came across this little snippet... and thought it was rather nice.
function validate(form) {var e = form.elements, m = ''; if(!e['firstname'].value) {m += '- First name is required. ';} if(!e['lastname'].value) {m += '- Last name is required. ';} if(!e['address'].value) {m += '- Address is required. ';} if(!e['city'].value) {m += '- City is required. ';} if(!e['postcode'].value) {m += '- Postcode is required. ';} if(!e['telephone'].value) {m += '- Telephone number is required. ';} m += '- E-mail requires a valid e-mail address. '; } if(!e['username'].value) {m += '- Username is required. ';} if(!e['password'].value) {m += '- Password is required. ';} if(e['password'].value != e['confirm'].value) { m += '- Your password and confirmation password do not match. '; } if(m) { alert('The following error(s) occurred: ' + m); return false; } return true; } </SCRIPT>
以上是关于基本注册表单验证的主要内容,如果未能解决你的问题,请参考以下文章