日期:2014-05-17 浏览次数:20888 次
<!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> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>Untitled Document</title> <script language="javascript"> function checkspace(checkstr) { var str = ''; for(i = 0; i < checkstr.length; i++) { str = str + ' '; } return (str == checkstr); } function checkuser(){ if(checkspace(document.form1.text.value)) { alert("your name is null"); document.form1.text.focus(); return false; } return true } </script> </head> <body> <form name="form1" action="#" method="post" onsubmit="return checkuser()"> <table width="200" border="0" cellspacing="0" cellpadding="0"> <tr> <td>name: <input type="text" size="20" name="text" /></td> </tr> <tr> <td><input type="submit" name="submit" value="提交" /></td> </tr> </table> </form> </body> </html>