<input name="username" id="reg_username" type="text" size="30"
onblur="func(this)"></td>
<td width="20%" id="td1">4-20个字符,可用中文、字母、数字注册</td>
function func(a){
if(check(a.value) == true){
document.getElementById("td1").innerText="该用户名可以注册";
}else{
document.getElementById("td1").innerText="您输入的用户名有误";
}
}
onblur="func(this)"></td>
<td width="20%" id="td1">4-20个字符,可用中文、字母、数字注册</td>
function func(a){
if(check(a.value) == true){
document.getElementById("td1").innerText="该用户名可以注册";
}else{
document.getElementById("td1").innerText="您输入的用户名有误";
}
}
解决方案 »
- JS图片放大问题 求大侠,急急急
- 不修改IE安全性,使用new ActiveXObject("WScript.Shell")如何不弹出提示?
- 如何用前一个select控制后一个select下拉菜单(诚恳求助)
- 难题!100分征集解决方法
- 鼠标移到图片上,图片的右上角显示一个小叉叉,是怎么做的?
- 如何截取字符串"a /b /c /d /",得到a,b,c,d
- 遇到难题了,请求帮助!!!关于页面传参数的问题
- 如何在一个frame里存取另一个frame里的变量?
- 请问:input框 自动增加"-".
- 200分大奉献(这里先给100分,完全解决再给100分)
- 请问如何设置页面的hotkey
- 字符串加变量的问题
<script language="javascript">
function func(a){
if(a.value.length>=4&&a.value.length<=20){
document.getElementById("td1").innerText="该用户名可以注册";
}else{
document.getElementById("td1").innerText="4-20个字符,可用中文、字母、数字注册";
}
}</script>
<table width="572">
<tr>
<td width="38%">
<input name="username" id="reg_username" type="text" size="30" onpropertychange="func(this)">
</td>
<td width="62%" id="td1">4-20个字符,可用中文、字母、数字注册</td>
</tr>
</table>
function checkPassword(obj)
{
if(/^[\u4e00-\u9FA5a-zA-Z0-9]{6,20}$/.test(obj.value))
{
if(obj.value!=document.getElementById("reg_username").value)
{
obj.parentNode.nextSibling.innerHTML="密码可以"
}
else
{
obj.parentNode.nextSibling.innerHTML="用户名密码不能相同"
}
}
else
{
obj.parentNode.nextSibling.innerHTML="密码输入有误,密码必须6-20个字符,可用字母、数字,且不能与用户名相同"
}
}
function checkConfirm(obj)
{
if(obj.value!=document.getElementById("reg_password").value)
{
obj.parentNode.nextSibling.innerHTML="密码确认错误";
}
else
{
obj.parentNode.nextSibling.innerHTML="密码确认正确";
}
}
</script>
<table>
<form action="" method="post" name="reg_info">
<tr>
<td width="20%">用户名:</td>
<td width="60%"><input name="username" id="reg_username" type="text" size="30" onblur="if(/^[\u4e00-\u9FA5a-zA-Z0-9]{4,20}$/.test(this.value)){this.parentNode.nextSibling.innerHTML='可以注册'}else{this.parentNode.nextSibling.innerHTML='不可以注册,用户名必须是4-20个字符,可用中文、字母、数字'}"></td>
<td width="20%">4-20个字符,可用中文、字母、数字注册</td>
</tr>
<tr>
<td width="20%">密码:</td>
<td width="60%"><input name="password" id="reg_password" type="password" size="30" onblur="checkPassword(this)"></td>
<td width="20%">6-20个字符,可用字母、数字,不能与用户名相同。</td>
</tr>
<tr>
<td width="20%">重复输入密码:</td>
<td width="60%"><input name="password1" id="reg_password1" type="password" size="30" onblur=checkConfirm(this)></td>
<td width="20%">请再次出入您上面填写的密码</td>
<tr>
</form>
</table>
但现在有一个新的问题,如何使
if(obj.value!=document.getElementById("reg_username").value)
{
obj.parentNode.nextSibling.innerHTML="密码可以"
}
中的"密码可以"这四个字变为红色?
onblur="processResult(this)"></td>
<td width="20%" id="td1">4-20个字符,可用中文、字母、数字注册</td>
function processResult(o){
if(o.value.length>=4 && o.value.length<=20){
document.getElementById("td1").innerText="该用户名可以注册";
}else{
document.getElementById("td1").innerText="您输入的用户名有误";
}
}