表单内容
<form name="reg">
<input type="text" name="userName" id="userName">
<input type="password" name="password1" id="password1">
<input type="password" name="password2" id="password2"><span id="promu"></span>
<input type="text" name="nickName" id="nickName">
<input type="text" name="address" id="address">
<input type="text" name="email" id="email">
</form>目标: 输入了password2后判断password1和password2中内容是否一致。不一致则出现在promu标签内表单提交时,依次检查每个表单,若有任何一个为空则不提交,并且弹出对话框提示(where is null)
还要检查email的格式是否正确
!谢谢大家了
<form name="reg">
<input type="text" name="userName" id="userName">
<input type="password" name="password1" id="password1">
<input type="password" name="password2" id="password2"><span id="promu"></span>
<input type="text" name="nickName" id="nickName">
<input type="text" name="address" id="address">
<input type="text" name="email" id="email">
</form>目标: 输入了password2后判断password1和password2中内容是否一致。不一致则出现在promu标签内表单提交时,依次检查每个表单,若有任何一个为空则不提交,并且弹出对话框提示(where is null)
还要检查email的格式是否正确
!谢谢大家了
解决方案 »
- struts2 s:generator 标签生成的list如何判断其长度
- 关于jsf弹出popup画面的问题
- 有点难度的问题
- 面试中遇到的一个问题,关于jsp中值传递的!哪位教教我!!!
- 那位高手可以给好一点的数据库连接池
- JSP和数据库问题
- 我出100分,大家来考论一下这个问题,相信大家工作中都遇到过这样的问题,谢谢!
- 怎样在点击时弹出对话框输入用户名密码验证呢 ??可以另给分
- 请问但出现Method getWeekDays() not found in class java.text.DateFormatSymbols时,如何办?
- hhaibin(小海) 请前来取分,谢谢。(4)
- mvc2模式中,是不是流程控制都用servlet来做?
- 求助,关于数据库插入的问题
{
$(promu).innerHTML="不一致";
}
function on_submit()
{//验证合法性
if(reg.password1.value!=reg.password2.value)
{
alert("您的账号前后不相同,请重新输入您的账号!");
form1.promu.focus();
return false;
}
if(reg.userName.value=="")
{
alert("您的用户名不能为空,请重新输入您的用户名!");
form1.userName.focus();
return false;
}
if(reg.nickName.value=="")
{
alert("------------");
form1.nickName.focus();
return false;
}
if(reg.address.value=="")
{
alert("-------------");
form1.address.focus();
return false;
}
if(reg.email.value=="")
{
alert("你的邮箱不能为空!");
form1.email.focus();
return false;
}
if(!reg.email.value.contains("@"))
{
alert("您的email格式不对!");
form1.email.focus();
return false;
}
}
</script><form name="reg" action="****" onsubmit="return on_submit()">
<form name="reg">... </form> var _form = document.getElementByNames("reg");
var _wrong=-1;
for(var i=0;i<form .length;i++){
if(form[i].password1.value!=form[i].password2.value ){
wrong = i;
break;
}
}
if(_wrong!=-1){
alert();
}
//check mail
function isEMail(cValue1) {
var eMail_regexp = new RegExp;
eval("eMail_regexp = /^[-\\.\\w]+\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$/;");
return eMail_regexp.test(cValue1);
}
<!--
function checkEmail(check_obj)
{//检查Email格式是否正确
if(check_obj.search(/^[\w-.]+@[\w-]+(\.[A-Za-z0-9]{2,})+$/)>=0){
return true;
}else{
return false;
}
} function checkForm(form){
var inputs = form.getElementsByTagName("INPUT");
for (var ii=0;ii< inputs.length; ii++)
{
if (inputs[ii].value == "")
{
alert(inputs[ii].name + "不能为空!");
inputs[ii].focus();
return false;
} if (inputs[ii].name == "password2" && inputs[ii].value!=inputs[ii-1].value)
{
document.getElementById("promu").innerHTML = "密码不一致";
inputs[ii].focus();
return false;
} if (inputs[ii].name == "email" && !checkEmail(inputs[ii].value))
{
alert("Email非法");
inputs[ii].focus();
return false;
}
}
return true;
}
//-->
</SCRIPT>
<form name="reg" onsubmit="return checkForm(this);">
<input type="text" name="userName" id="userName">
<input type="password" name="password1" id="password1">
<input type="password" name="password2" id="password2"> <span id="promu"> </span>
<input type="text" name="nickName" id="nickName">
<input type="text" name="address" id="address">
<input type="text" name="email" id="email">
<input type="submit" value="Submit">
</form>
</BODY>