日期:2014-05-16 浏览次数:20405 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> text javascript </title> <script language="javascript"> function test(obj) { if(obj.username.value=="") { alert("用户名不能为空"); obj.username.value=""; return false; } if(obj.userpwd.value=="") { alert("密码不能为空"); obj.userpwd.value=""; return false; } if(obj.email.value=="") { alert("Email不能为空"); obj.email.value=""; return false; } return true; } </script> </head> <body> <form method="post" action="hh.html" name="form" onsubmit="return test (form)"> <table> <tr> <td> 用户名:</td> <td> <input type="text" id="username" /></td></tr> <tr> <td> 密码:</td> <td> <input type="password" id="userpwd" /></td></tr> <tr> <td> Email:</td> <td> <input type="text" id="email" /></td></tr> <tr> <td><input type="submit" id="submit" value="提交" onclick="text"></td></tr> </table> </form> </body> </html>