表单验证

xiaoxiao2021-02-28  90

<!DOCTYPE html> < html lang=" en"> < head> < title></ title> < meta charset=" UTF-8"> < link href=" css/style.css" rel=" stylesheet"> </ head> < script language=" Javascript"> function check() { if( form1. username.value=="" && form1. pwd.value=="" && form1. pwd1.value=="") { alert (" 错误提示:请将所有资料填写完整!"); return false; } if( form1. username.value=="") { alert (" 错误提示:用户名不能为空!"); return false; } if ( form1. pwd.value=="") { alert (" 错误提示:密码不能为空!"); return false; } if ( form1. pwd1.value=="") { alert (" 错误提示:账号不能为空!"); return false; } return true; } </ script> < body> < form id=" form1" runat=" server" name=" form1" action="" onsubmit=""> < p align=" center"> 用户名: < input type=" text" name=" username" /> < p align=" center"> 密码:< input type=" password" name=" pwd" /> < p align=" center"> 账号:< input type=" password" name=" pwd1" /> < input type=" submit" value=" 登录" onclick=" return check()"> </ form> </ body> </ html>
转载请注明原文地址: https://www.6miu.com/read-71351.html

最新回复(0)