亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

JavaScript ?? ??? ??

JavaScript ?? ??? ??


JavaScript ?? ??? ??

JavaScript? ???? ??? ???? ?? HTML ???? ??? ?? ???? ???? ???? ? ??? ? ????.

?? ???? ???? ????? ?? JavaScript? ?????.

?? ???? ?? ??? ?????????

??? ??? ??? ???? ?????????

??? ??? ?????? ???????

?? ?? ??? ???? ???????

??(?? ??) ??

?? ??? ???? ??? ??(?? ??) ??? ????? ???? ? ?????. ?? ?? ?? ?? ??? ?? ??? ?? ??? ???? ??? ?? ?? false???. ??? ??? ??? ?? ?? true???(???? ??? ??? ??):

?? verifyForm()
{
var x =document.forms["myForm"]["fname"].value;
if (x==null || x=="")
{
Alert("?? ??? ??? ???. filled in");
return false;
}
}

? ??? ??? ??? ? ?????.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<head>
<script>
function validateForm(){
var x=document.forms["myForm"]["fname"].value;
if (x==null || x==""){
  alert("姓必須填寫");
  return false;
  }
}
</script>
</head>
<body>    
<form name="myForm" action="demo-form.php" onsubmit="return validateForm()" method="post">
姓: <input type="text" name="fname">
<input type="submit" value="提交">
</form>  
</body>
</html>

??? ??

?? ??? ??? ???? ??? ????? ?????. ??? ??? ?? ??.

?? ?? ???? @ ??? ???(.)? ????? ?? ?????. ??? @? ??? ??? ? ?? ??? ? ? ??? @ ?? ???? ?? ?? ??? ???.

function verifyForm(){
var x=document.forms["myForm"]["email" ].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>= x.length){
Alert("??? ??? ??? ????");
return false;
}
}

??? HTML ??? ?? ?? ?????.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<head>
<script>
function validateForm(){
    var x=document.forms["myForm"]["email"].value;
    var atpos=x.indexOf("@");
    var dotpos=x.lastIndexOf(".");
    if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length){
        alert("不是一個(gè)有效的 e-mail 地址");
        return false;
    }
}
</script>
</head>
<body>    
<form name="myForm" action="demo-form.php" onsubmit="return validateForm();" method="post">
Email: <input type="text" name="email">
<input type="submit" value="提交">
</form>    
</body>
</html>


???? ??
||
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>表單驗(yàn)證</title> <script type="text/javascript"> //校驗(yàn)輸入 function checkInput(){ var flag=false; var username=$("username").value; var pwd=$("pwd").value; var repwd=$("repwd").value; var email=$("email").value; if(username==""){ alert("用戶名不能為空!"); }else if(pwd==""){ alert("密碼不能為空!"); }else if(pwd.length<6){ alert("密碼必須大于6位"); }else if(pwd!=repwd){ alert("密碼不一致!"); }else if(email.indexOf("@")==-1 ||email.indexOf(".")==-1){ alert("郵箱格式不正確!"); }else{ flag=true; } //限定用戶名不能包含數(shù)字 for(var i=0;i<username.length;i++){ var s=username.substring(i,i+1); if(!isNaN(s)){ alert("用戶名不能包含數(shù)字!") return false; } } return flag; } //獲取焦點(diǎn)時(shí)清除原內(nèi)容 function clearUsername(){ var username=$("username"); username.style.border="1px solid #f00"; if(username.value=="請輸入正確的用戶名"){ username.value=""; } } //失去焦點(diǎn)時(shí)檢驗(yàn)用戶名 function checkUsername(username){ username.style.border=""; if(username.value==""){ $("usernameinfo").style.font="normal 15px 宋體"; $("usernameinfo").style.color="#f00"; $("usernameinfo").innerHTML="用戶名不能為空"; username.focus(); }else if(username.value.length>14||username.value.length<6){ $("usernameinfo").style.font="normal 15px 宋體"; $("usernameinfo").style.color="#F00"; $("usernameinfo").innerHTML="用戶名長度必須在6-14之間!"; //username.select();//此代碼在IE和Chrome中好使,在Firefox中不好使 //匿名函數(shù) setTimeout(function(){username.select();},0); }else{ $("usernameinfo").innerHTML=""; } } function $(id){ return document.getElementById(id); } </script> </head> <body> <form action="success.html" method="post" onsubmit="return checkInput();"> <table border="0" cellpadding="0" cellspacing="0" width="600px"> <tr> <td align="right">用戶名:</td> <td><input type="text" name="userbname" id="username" value="請輸入正確的用戶名" onfocus="clearUsername()" onblur="checkUsername(this)"/><span id="usernameinfo"></span></td> </tr> <tr> <td align="right">密碼:</td> <td><input type="password" name="pwd" id="pwd"/></td> </tr> <tr> <td align="right">確認(rèn)密碼:</td> <td><input type="password" name="repwd" id="repwd"/></td> </tr> <tr> <td align="right">電子郵箱:</td> <td><input type="text" name="email" id="email"/><br/></td> </tr> <tr> <td></td> <td>  <input type="submit" value="注冊"/>  <input type="reset" value="重置"/></td> </tr> </table> </form> </body> </html>