js注冊表單
Ⅰ 編寫HTML注冊表單,,javascript表單驗證
汗。。。。閣下語氣可以舒緩一些嗎?
我們抽出自己的時間來幫助別人,不是來聽人吩咐的,
希望閣下能夠注意點,語氣緩和一些總可以吧,別搞得跟老師似的
我已經把代碼寫好了,效果如圖,代碼放在這兒了,請下載吧
Ⅱ 在哪裡填寫JavaScript注冊表單
你的問題跟你說的那個答案 完全不沾邊,你的問題應該是,你的網速太慢了,代碼沒有載入專完全,執行的過屬程中出問題了,或者你的瀏覽器禁用了JavaScript的,網速問題,你就刷新幾下,不行換個時間,禁用了JavaScript,如果是ie,在菜單欄中「工具」中選擇「Internet選項」–>「安全」選項卡–>選擇「Internet」(藍色的小地球)–>「自定義級別」–>找到「腳本」下的「Java小程序腳本」中進行啟用和禁用。
Ⅲ javascript實現一個學生注冊表單
<head>
<title>注冊</title>
</head>
<body>
<form>
<table>
<colwidth=40%>
<colwidth=60%>
<tr>
<td>姓名:</td><td><inputtype="text"id="name"></td>
</tr>
<tr>
<td>性別:</td>
<td>
<inputtype="radio"name="sex"value="male">男
<inputtype="radio"name="sex"value="female">女
</td>
</tr>
<tr>
<td>年齡:</td><td><inputtype="text"id="age"onkeydown="onlyNumber()">
</tr>
<tr>
<td>電話號碼:</td><td><inputtype="text"id="phone"onkeydown="onlyNumber()">
</tr>
</table>
</form>
</body>
<scripttype="text/javascript">
functiononlyNumber(){
varcode=window.event.keyCode;
if(code>=48&&code<=57||code==8){
window.event.returnValue=true;
}else{
window.event.returnValue=false;
}
}
</script>
Ⅳ 我用JS做了一個彈出注冊的表單,這種表單要如何驗證其中的用戶名和密碼,謝謝!
你要驗證用戶名和密碼的輸入格式么?
可以用正則匹配來判斷
Ⅳ JSP中用js實現注冊表單的驗證
jquery的框架 有自帶的驗證 都是別人幫你寫好的
看能不能符合你的
Ⅵ JavaScript注冊表單的驗證
function isCharsNotInBag (s, bag)
{
var i,c;
for (i = 0; i < s.length; i++)
{
c = s.charAt(i);
if (bag.indexOf(c) < 0)
return true;
}
return false;
} function InValidChar(s)
{
var haserrorChar;
var CorrectChar = ""
haserrorChar = isCharsNotInBag(s, CorrectChar);
return haserrorChar;
}
function orderuser(strs)
{
if (InValidChar(strs))
{
document.getElementById("uname").innerHTML ="用戶名只能使用英文加數字組合";
document.getElementById("txtName").focus();
return;
}
if(strs.length<5)
{
document.getElementById("uname").innerHTML ="用戶名不能低於5位";
document.getElementById("txtName").focus();
return;
}
var xmlHttp = new XMLHttpRequest();
var url="reg_ajax.aspx";
url= addparam(url,"users",strs);
url= addparam(url,"types","select");
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
document.getElementById("uname").innerHTML = xmlHttp.responseText;
if(xmlHttp.responseText=="該用戶名可以使用")
{
document.getElementById("txtPwd").focus();
document.getElementById("txtName").readOnly=true;
}
else
{
document.getElementById("txtName").focus();
}
}
}
}
function checkpwd()
{
var pwd = document.getElementById("txtPwd").value;
if (pwd.length<6)
{
document.getElementById("pwd").innerHTML="密碼不能低於6位";
document.getElementById("txtPwd").focus();
return;
}
else
{
if (document.getElementById("txtPwd").value==document.getElementById("txtPwd2").value)
{
document.getElementById("pwd").innerHTML="兩次密碼相同";
document.getElementById("txtPwd").readOnly=true;
document.getElementById("txtPwd2").readOnly=true;
document.getElementById("Button1").disabled = "";
}
else
{
document.getElementById("pwd").innerHTML="兩次密碼不同";
document.getElementById("txtPwd").focus();
}
}
}
function checkform()
{
if (document.getElementById("yanzhengma").value.length<4)
{
alert("請輸入驗證碼");
return;
}
else
{
var urlstr="regditaccept.aspx?uname=" + document.getElementById("txtName").value + "&upwd=" + document.getElementById("txtPwd").value + "&yzm=" + document.getElementById("yanzhengma").value +"&email="+ document.getElementById("txtMailbox").value ;
window.location.href=urlstr;
}
} <!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>無標題頁</title>
<script type="text/javascript" src="../js/public_ajax.js"></script>
<script type="text/javascript" src="../js/reg_other.js">
</script>
</head>
<body onload="javascript:document.getElementById('txtName').focus();">
<form>
<table bgcolor="#cccccc" border="0" cellpadding="2" cellspacing="1" style="width: 477px;
height: 156px">
<tr>
<td align="center" bgcolor="#f7f7f7" width="80">
<span style="font-size: 10pt">用戶名稱:</span></td>
<td align="left" bgcolor="#f7f7f7" width="427">
<p>
<input id="txtName" name="txtName" onblur="orderuser(this.value)"
style="width: 185px" type="text" />
<span style="font-size: 10pt;color: #990000"><span class="hong1">*</span></span><span
id="uname" style="font-size: 10pt; color: #cc0000"></span></p>
</td>
</tr>
<tr>
<td align="center" bgcolor="#ffffff">
<span style="font-size: 10pt">您的密碼:</span></td>
<td align="left" bgcolor="#ffffff">
<input id="txtPwd" maxlength="20" name="txtPwd" style="width: 185px"
type="password" />
<span class="hong1"><span style="font-size: 10pt; color: #990000">*</span> <span
id="rfv_Pwd" style="display: none; color: red"></span> </span>
</td>
</tr>
<tr>
<td align="center" bgcolor="#f7f7f7">
<span style="font-size: 10pt">確認密碼:</span></td>
<td align="left" bgcolor="#f7f7f7">
<input id="txtPwd2" maxlength="20" name="txtPwd2" onblur="checkpwd()" style="width: 185px"
type="password" />
<span class="hong1"><span style="font-size: 10pt; color: #990000">* </span><span
id="pwd" style="font-size: 10pt; color: #cc0000"></span></span></td>
</tr>
<tr>
<td align="center" bgcolor="#f7f7f7">
<span style="font-size: 10pt">電子郵箱:</span></td>
<td align="left" bgcolor="#f7f7f7">
<input id="txtMailbox" class="text1" name="txtMailbox" style="width: 185px"
type="text" /></td>
</tr>
<tr>
<td align="center" bgcolor="#ffffff" style="height: 28px">
<span style="font-size: 10pt">驗證碼:</span></td>
<td align="left" bgcolor="#ffffff" style="height: 28px">
<input id="yanzhengma" type="text" width="110px" style="width: 97px" /><iframe frameborder="0"
scrolling="no" src="yanzhengma.aspx" style="width: 68px;
height: 22px"></iframe>
<span style="font-size: 10pt; color: #990000">(點擊圖片刷新驗證碼)</span></td>
</tr>
<tr>
<td align="center" bgcolor="#f7f7f7" colspan="2" nowrap="nowrap">
<input id="Button1" onclick="checkform()" disabled="disabled" style="border-right: #000000 1px solid; border-top: #000000 1px solid;
border-left: #000000 1px solid; width: 64px; border-bottom: #000000 1px solid;
height: 26px; background-color: #ff9900" type="button" value="注冊" />
<input id="Button2" style="border-right: #000000 1px solid; border-top: #000000 1px solid;
border-left: #000000 1px solid; width: 64px; border-bottom: #000000 1px solid;
height: 26px; background-color: #ff9900" type="reset" value="重置" /></td>
</tr>
</table>
</form>
</body>
</html>
Ⅶ 求份完整的JS注冊表單驗證
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
form.input,div{margin:0; padding:0;}
body{font-size:12px; margin:0; padding:0;}
#login{width:1151; height:624px;}
.parent{width:100%; height:27px; line-height:27px;}
.parent label{display:inline-block;width:333px; height:27px;line-height:27px; text-align:right;}
.bor{padding-left:333px; color:#999;}
.three{width:308px; height:25px; border:1px solid #999;}
#email{width:196px; height:25px; border:1px solid #999;}
.wrong{background:url(images/wrong.png) no-repeat; padding-left:25px; color:#F00; display:inline-block; height:25px; line-height:25px;}
.right{background:url(images/right.png) no-repeat; padding-left:25px; color:#00F; display:inline-block; height:25px;line-height:25px;}
</style>
<title>注冊界面</title>
</head>
<body>
<div id="login">
<form action="form" method="get" name="login" style="margin-top:24px">
<div class="parent"><label>郵箱地址:</label><input type="text" id="email" /> @
<select style="width:86px; height:20px;">
<option value="163.com">163.com</option>
<option value="126.com">126.com</option>
<option value="yeah.net">yeah.net</option>
</select>
</div>
<div class="bor">6-18個字元,區分大小寫</div>
<div class="parent"><label>密碼:</label><input type="password" id="pwd" class="three" /></div>
<div class="bor">6-16個字元,區分大小寫</div>
<div class="parent"><label>確認密碼:</label><input type="password" id="dpwd" class="three" /></div>
<div class="bor">請再次輸入密碼</div>
<div class="parent"><label>手機號碼:</label><input type="text" id="phoneNum" class="three" /></div>
<div class="bor">密碼遺忘或被盜時,可通過手機簡訊取回密碼</div>
<div class="parent"><label>驗證碼:</label><input type="text"/></div>
<input type="button" id="dad" value="注冊" style="position:relative;left:333px;" />
</form>
</div>
<script type="text/javascript">
for(i=0;i<4;i++){
document.getElementsByTagName("input")[i].onfocus=function(){
}
document.getElementsByTagName("input")[i].onblur=function(){
var spanLength=this.parentNode.getElementsByTagName("span").length;
if(spanLength>0){
this.parentNode.removeChild(this.nextSibling)
}
var id=this.getAttribute("id");
if(id=="email"){
emailReg=/^\w{6,18}$/
if(!emailReg.test(this.value)){
span=document.createElement("span")
spanTxt=document.createTextNode("您輸入的格式有錯誤")
span.className="wrong"
span.appendChild(spanTxt)
this.parentNode.appendChild(span)
}else{
span=document.createElement("span")
spanTxt=document.createTextNode("恭喜您輸入正確")
span.className="right"
span.appendChild(spanTxt)
this.parentNode.appendChild(span)
}
}
if(id=="pwd"){
pwdReg=/^\w{6,16}$/
if(!pwdReg.test(this.value)){
span=document.createElement("span")
spanTxt=document.createTextNode("您輸入的格式有錯誤")
span.className="wrong"
span.appendChild(spanTxt)
this.parentNode.appendChild(span)
}else{
span=document.createElement("span")
spanTxt=document.createTextNode("恭喜您輸入正確")
span.className="right"
span.appendChild(spanTxt)
this.parentNode.appendChild(span)
}
}
if(id=="dpwd"){
if(this.value!=document.getElementById("pwd").value||this.length<=0){
span=document.createElement("span")
spanTxt=document.createTextNode("您輸入的格式有錯誤")
span.className="wrong"
span.appendChild(spanTxt)
this.parentNode.appendChild(span)
}else{
span=document.createElement("span")
spanTxt=document.createTextNode("恭喜您輸入正確")
span.className="right"
span.appendChild(spanTxt)
this.parentNode.appendChild(span)
}
}
if(id=="phoneNum"){
phoneReg=/^1[3|4|5|8]\d{9}$/
if(!phoneReg.test(this.value)){
span=document.createElement("span")
spanTxt=document.createTextNode("您輸入的格式有錯誤")
span.className="wrong"
span.appendChild(spanTxt)
this.parentNode.appendChild(span)
}else{
span=document.createElement("span")
spanTxt=document.createTextNode("恭喜您輸入正確")
span.className="right"
span.appendChild(spanTxt)
this.parentNode.appendChild(span)
}
}
}
document.login.getElementsByTagName("input")[i].onkeyup=function(){
this.blur();
this.focus();
}
}
document.getElementById("dad").onmousedown=function(){//onmousedown按下滑鼠鍵
for(i=0;i<4;i++){
document.login.getElementsByTagName("input")[i].focus();//對所有的文本框進行驗證
document.login.getElementsByTagName("input")[i].blur();//取消聚集
}
}
document.getElementById("dad").onmouseup=function(){//onmouseup彈起滑鼠鍵
var errorNum=0;//
for(i=0;i<document.login.getElementsByTagName("span").length;i++){
if(document.login.getElementsByTagName("span")[i].className=="wrong"){
errorNum++;//加一次
}
}
if(errorNum==0){
document.login.submit()
}else{
alert("填寫錯誤,請重新輸入正確的內容。")
}
}
</script>
</body>
</html>
自己寫著玩的
最好自己再修改下,看不懂我就沒辦法了。
Ⅷ 求一個用javascript寫的驗證注冊表單
<table>
<tr>
<td>昵稱</td>
<td><inputtype="text"id="nickName"/></td>
<tdstyle="color:red;display:none"id="enickName">昵稱不能大於10個字</td>
</tr>
<tr>
<td>密碼</td>
<td><inputtype="password"id="pass1"/></td>
<tdstyle="color:red;display:none"id="epass1">密碼應為字母加數字,且字數在6-12個字內</td>
</tr>
<tr>
<td>確認密碼</td>
<td><inputtype="password"id="pass2"/></td>
<td></td>
</tr>
<tr>
<td>Email</td>
<td><inputtype="text"id="email"/></td>
<td></td>
</tr>
<tr>
<td>姓名</td>
<td><inputtype="text"id="name"/></td>
<tdstyle="color:red;display:none"id="ename">姓名2-4個漢字,或不限數的英文</td>
</tr>
<tr>
<td>驗證碼</td>
<td><inputtype="text"id="code"/></td>
<td></td>
</tr>
<tr>
<tdcolspan="2">
<inputtype="button"value="提交"onclick="check();"/>
</td>
<td></td>
</tr>
</table>
<scriptlanguage="javascript">
$=function(id){returndocument.getElementById(id);}
functioncheck(){
if($("nickName").value.length>10){
$("nickName").style.backgroundColor="red";
$("enickName").style.display="";
}else{
$("nickName").style.backgroundColor="";
$("enickName").style.display="none";
}if($("pass1").value.length>12||$("pass1").value.length<6||!$("pass1").value.match(/[0-9]/)||!$("pass1").value.match(/[a-zA-Z]/)){
$("pass1").style.backgroundColor="red";
$("epass1").style.display="";
}else{
$("pass1").style.backgroundColor="";
$("epass1").style.display="none";
}if(!$("name").value.match(/^[u4e00-u9fa5]{2,4}$/)&&!$("name").value.match(/^[a-zA-Z]+$/)){
$("name").style.backgroundColor="red";
$("ename").style.display="";
}else{
$("name").style.backgroundColor="";
$("ename").style.display="none";
}
}
</script>
Ⅸ js注冊表單驗證代碼
||JS函數:
functioncheck(){
varusername=document.getElementById("username").value;
varpass1=document.getElementById("password").value;
varpass2=document.getElementById("confirm_password").value;
if(username==""||username==NULL||pass1==""||pass1==NULL||pass2==NULL||pass2==""){
alert("用戶名或密碼不得為空!");
returnfalse;
}
}
表單提交版的時候驗證:權
<inputname="reg"type="submit"value="提交"onclick="returncheck()"/>
自己補全。
Ⅹ JS表單注冊驗證
把以下代碼加到來body里試源一試 本應寫成function 就是做個示意給你看看原理
昵稱:
<inputtype="text"onclick="this.style.border='1px#cd1b1bsolid';document.getElementById('a').innerHTML='';"onblur="this.style.border='1px#000000solid';if(this.value==''){document.getElementById('a').innerHTML='昵稱不能為空!';}"/><spanid="a"></span><br/><br/>
密碼:
<inputtype="text"onclick="this.style.border='1px#cd1b1bsolid';document.getElementById('b').innerHTML='';"onblur="this.style.border='1px#000000solid';if(this.value==''){document.getElementById('b').innerHTML='密碼不能為空!';}"/><spanid="b"></span>