`
PerformerY
  • 浏览: 4402 次
社区版块
存档分类
最新评论

JS基础练习1-7

JS 
阅读更多
<!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=utf-8" />
<title>练习七</title>
<script>
var num1=0;

function Result(){
var num1val=document.getElementById("username").value;
if (num1val!=0){
alert("测试成功!");
}
else
document.getElementById("checkname").innerHTML="<font color='red'>用户名不能为空!</font>";

}

</script>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
  <table width="422" height="58" border="1" cellspacing="0" cellpadding="1">
    <tr>
      <td width="110" height="29">用户名:</td>
     
      <td width="180"><label for="username"></label>
      <input type="text" name="username" id="username" /></td>
     
      <td width="110" id="checkname"></td>
    </tr>
    <tr>
      <td height="23" colspan="3"><input type="button" name="ceshi" id="ceshi" value="测试" onclick="Result();" /></td>
    </tr>
  </table>
</form>
</body>
</html>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics