社区
ASP
帖子详情
输入学号作判断必须9位且为数字怎么写?
jshao
2003-06-19 10:25:34
如题
判断位数字行了,必须为9位不知怎么判断
在下面代码补充一下行吗?
<input name="student_number" type="text" id="student_number" onchange="if(/\D/.test(this.value)){alert('只能输入数字');this.value='';}">
...全文
765
8
打赏
收藏
输入学号作判断必须9位且为数字怎么写?
如题 判断位数字行了,必须为9位不知怎么判断 在下面代码补充一下行吗?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
8 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
jshao
2003-06-20
打赏
举报
回复
谢谢各位了!真是不少!
blueice2002
2003-06-19
打赏
举报
回复
这很全的。
blueice2002
2003-06-19
打赏
举报
回复
<script language="javascript">
function IsDigit(cCheck)
{
return (('0'<=cCheck) && (cCheck<='9'));
}
function IsAlpha(cCheck)
{
return ((('a'<=cCheck) && (cCheck<='z')) || (('A'<=cCheck) && (cCheck<='Z')))
}
function IsaNull(cCheck)
{
return(cCheck != " ")
}
function checkform()
{
strUserID = document.sform1.username.value;
if (strUserID == "")
{
alert("请输入注册名");
document.sform1.username.focus();
return false;
}
for (nIndex=0; nIndex<strUserID.length; nIndex++)
{
cCheck = strUserID.charAt(nIndex);
if (!(IsDigit(cCheck) || IsAlpha(cCheck) || cCheck=='-' || cCheck=='_' || cCheck=='.'))
{
alert("用户名只能使用字母、数字以及-、_和.,并且不能使用中文");
document.sform1.username.focus();
return false;
}
}
if (document.sform1.userpassword.value == "")
{
alert("请输入密码.");
document.sform1.userpassword.focus();
return (false);
}
if (document.sform1.userpassword.value.length > 12)
{
alert("密码长度应小于12.");
document.sform1.user_password.focus();
return (false);
}
if (document.sform1.userpassword.value != document.sform1.password2.value)
{
alert("两次密码不相同,请重新输入密码.");
document.sform1.password2.focus();
return (false);
}
if (document.sform1.email.value == "")
{
alert("请输入您的E-MAIL地址");
document.sform1.email.focus();
return false;
}
if (document.sform1.email.value.length >50 )
{
alert("您输入的E-MAIL地址不能大于50个字符,否则超出部分会被截断");
document.sform1.email.focus();
return false;
}
personnm=document.sform1.personalid.value;
if (personnm=="")
{
alert("您的证件号码不能为空");
document.sform1.personalid.focus();
return false;
}
else
{
var i;
for(var i=0;i<document.sform1.perid.length;i++)
{
if (document.sform1.perid[0].checked)
{
if ((personnm.length != 15) && (personnm.length != 18))
{
alert("您的身份证号码必须是15位或18位的数字");
document.sform1.personalid.focus();
return false;
}
}
}
}
strUseroicq = document.sform1.oicq.value;
if (strUseroicq == "")
{
alert("OICQ不能为空!");
document.sform1.oicq.focus();
return false;
}
for (nIndex=0; nIndex<strUseroicq.length; nIndex++)
{
cCheck = strUseroicq.charAt(nIndex);
if (!(IsDigit(cCheck)))
{
alert("OICQ只能使用数字");
document.sform1.oicq.focus();
return false;
}
}
sname=document.sform1.realname.value;
if (sname == "")
{
alert("请输入您的真实姓名");
document.sform1.realname.focus();
return false;
}
for (nIndex=0; nIndex<sname.length; nIndex++)
{
cCheck = sname.charAt(nIndex);
if (!(IsaNull(cCheck)))
{
alert("真实姓名不能是空格");
document.sform1.realname.focus();
return false;
}
}
nian=document.sform1.y1.value
if ((nian == "") || (nian.length!=4))
{
alert("请输入您的生日");
document.sform1.y1.focus();
return false;
}
if (document.sform1.tel.value == "")
{
alert("请输入您的电话");
document.sform1.tel.focus();
return false;
}
if (document.sform1.address.value == "")
{
alert("请输入您的地址");
document.sform1.address.focus();
return false;
}
return true;
}
function clickc()
{
if (document.sform1.perid.checked==1)
{
//document.sform1.perid.disabled=0;
document.sform1.perid.value=0;
}
//else
// {
// document.sform1.personalid.disabled=1;
// document.sform1.personalid.value='*可凭自己的身份证取回丢失的密码*';
// }
}
</script>
wjh6of6agriculture
2003-06-19
打赏
举报
回复
<script language="vbscript">
if len(学号)=9 and isnumric(学号) then
......
else
msgbox "不行!"
end if
</script>
isnumric() : 是判断是否是数字的函数,但具体怎么写忘了,你翻看下书吧!
jesee
2003-06-19
打赏
举报
回复
正则匹配的问题,建议你看看这个方面的知识
纪俊
2003-06-19
打赏
举报
回复
if len(var(yournumber))<9 then Msgbox ("小于9位")
denghan
2003-06-19
打赏
举报
回复
<script language="javascript">
function check()
{
if (document.form1.idencode.value=="" || document.form1.idencode.value.length < 15 || (document.form1.idencode.value.length > 15 && document.form1.idencode.value.length <18)) {alert(".您的身份证号码为空或身份证号位数不正确\n 身份证号应为15位或者18位数字\n");
return false;}
</script>
<form name="form1" method="post" action="user_save.asp" onsubmit="return check()">
<input name=idencode
onKeyPress = "return regInput(this, /^\d{1,18}?$/, String.fromCharCode(event.keyCode))"
onpaste = "return regInput(this, /^\d{1,18}?$/, window.clipboardData.getData('Text'))"
ondrop = "return regInput(this, /^\d{1,618}?$/, event.dataTransfer.getData('Text'))"
style="ime-mode:Disabled">
您的身份证号码
<input type="submit" name="Submit" value="提交">
</form>
fason
2003-06-19
打赏
举报
回复
onchange="if(!/^\d{6}$/.test(this.value)){alert('只能输入数字');this.value='';}"
java怎样
判断
是否为八位
数字
_用正则表达式
判断
输入
的内容为8-16
位且
同时包含
数字
和字母...
1,不能全部是
数字
2,不能全部是字母3,
必须
是
数字
或字母1^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,16}$分开来注释一下:^ 匹配一行的开头位置(?![0-9]+$) 预测该位置后面不全是
数字
(?![a-zA-Z]+$) 预测该位置后面...
利用正则表达式
判断
输入
学号
是否正确
package study; import java.util.Scanner; public class better { public static void main...System.out.println(“请
输入
你的
学号
(十二位)”); Scanner sc=new Scanner(System.in); String k=sc.nextLine(); bo...
C语言
判断
输入
的是否为
数字
如果用户
输入
的不是字符,则循环提示用户
输入
1~9的有效
数字
void select_students( ){ int a = file_read(); char str[5] = {0}; printf("---------- 查询学生信息 ----------"); printf("\t\t1、按
学号
...
Android studio——
输入
学号
是否正确
输入
一串
学号
,
判断
输入
的
学号
xx是否正确,如果正确弹出登录成功,反之登录失败。 xml文件代码: <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:...
调用方法
判断
用户
输入
学号
是否合法,如果是以shxt开头,最后边4位是
数字
并且大于1000则为合格
public static boolean isNum(String str) {//
判断
字符串后四位是否是
数字
字符串 String trail=str.substring(str.length()-4, str.length()); System.out.println("后四位为:"+trail); boolean b=true; ...
ASP
28,404
社区成员
356,946
社区内容
发帖
与我相关
我的任务
ASP
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
复制链接
扫一扫
分享
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章