紧急求助,JS控制输入框只能输入以下值 第一个控制只能输入数字 5-10位,超过就提示第二个2个输入框同时输入一个密码,如果2个输入框密码不一样就提示第三个是这上面3个输入框必须输入,否则提示望给个答案,谢谢。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 第一题 加一个onkeydown事件第二题在第二个输入框中加入onmouseout事件第三题 在提交的时候加上非空的判断吧。。 楼主的问题提的不够清楚,都没说明是在什么时候验证,验证的方法其实很简单,我这里提供一下,至于什么时候调用,用什么事件调用就看楼主自己了1.假设第一个输入的ID为t1 即<input type='text' id='t1' />function checkNum(){ var t1=document.getElementById('t1').value; if(isNaN(t1)){ alert("请输入数字"); document.getElementById('t1').focus(); }else{ if(t1.length<5 || t1.length>10){ alert("请输入5-10位的数字"); document.getElementById('t1').focus(); } }}2.假设第一个密码框为p1 ,第二个为p2,即function checkPassWord(){ var p1=document.getElementById('p1').value; var p2=document.getElementById('p2').value; if(p1!=p2){ alert("两次输入的密码必须一致"); document.getElementById('p2').focus(); }}3.function checkSubmit(){ var t1=document.getElementById('t1').value; var p1=document.getElementById('p1').value; var p2=document.getElementById('p2').value; if(t1=""){ alert("请输入完整的资料") document.getElementById('t1').focus(); } if(p1=""){ alert("请输入完整的资料") document.getElementById('p1').focus(); } if(p2=""){ alert("请输入完整的资料") document.getElementById('p2').focus(); }} 用正则表达式过滤空格 Tomcat会自动加载并读取WEB-INF目录下面的XML配置文件吗 jsp如何读取并显示数据库中超链接文件内容 非常感谢!!! 想问一下,在struts标签中,action属性如何设置才能不让它进后台呢? 注册的时候验证电子信箱的逻辑应该怎么做? dwr页面即时更新 怎么去搜索别人网站上的东西?? javascript取整问题? 我在提取表中的自动增加字段内容时遇到的问题 求一份完整的搭建ssh流程 菜鸟菜问, 路过的高手指点指点 sql 怎么实现图片的存储和显示呢???
第二题在第二个输入框中加入onmouseout事件
第三题 在提交的时候加上非空的判断吧。。
1.假设第一个输入的ID为t1 即<input type='text' id='t1' />
function checkNum(){
var t1=document.getElementById('t1').value;
if(isNaN(t1)){
alert("请输入数字");
document.getElementById('t1').focus();
}else{
if(t1.length<5 || t1.length>10){
alert("请输入5-10位的数字");
document.getElementById('t1').focus();
}
}
}2.假设第一个密码框为p1 ,第二个为p2,即
function checkPassWord(){
var p1=document.getElementById('p1').value;
var p2=document.getElementById('p2').value;
if(p1!=p2){
alert("两次输入的密码必须一致");
document.getElementById('p2').focus();
}
}
3.function checkSubmit(){
var t1=document.getElementById('t1').value;
var p1=document.getElementById('p1').value;
var p2=document.getElementById('p2').value;
if(t1=""){
alert("请输入完整的资料")
document.getElementById('t1').focus();
}
if(p1=""){
alert("请输入完整的资料")
document.getElementById('p1').focus();
}
if(p2=""){
alert("请输入完整的资料")
document.getElementById('p2').focus();
}
}