function WidthCheck(s) {
var w = 0
for (var i = 0i <s.lengthi++) {
var c = s.charCodeAt(i)
//单字节加1
if ((c >= 0x0001 &&c <= 0x007e) || (0xff60 <= c &&c <= 0xff9f)) {
w++
}
//双字节加2
else {
w += 2
}
}
return w
}
/判断登录是否为空
if (document.getElementById("nameid").value== "") {
alert("登录名不能为空")
return false
}
//纯数字
var patrn=/^[0-9]*$/
if (!patrn.exec(document.getElementById("shuziid").value)){
alert("不是全数字")
}else{
alert("是全数字")
}
//判断电子邮箱格式是否正确
var MainEmail =document.getElementById("emial").value
var patrn=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/
if (!patrn.exec(MainEmail )){
alert("不是邮箱")
}else{
alert("是邮箱")
}
//判断密码长度 6-18之间
if (WidthCheck(document.getElementById("passwordid").value) <6 || WidthCheck(document.getElementById("passwordid").value) >18) {
alert(出生日期的月份必须是6-18之间)
return false
}
//验证用户输入的信息长度是否足够
if (WidthCheck(document.getElementById("passwordid").value) >6 ) {
alert(用户输入的信息长度是否大于6)
return false
}
//户输入的出生日期是否有效
这个自己去判断下根据当前选择的月份是奇数还是偶数。这是大致的一段代码,自己测试修改下。
/*** 打印 n 行的 * 塔
* *
* * *
** * *
* * * * *
* * * * * *
*/
function printStar(n) {
str = ""
for (var i=0i<ni++) { // 逐行构造要输出的字符串
// 添加每行开头的空格
for (var j=n-ij>1j--)
str += " "
// 添加每行的中的星号
for (var j=0j<=ij++)
str += "* "
// 最后加个换行符
str += "\r\n"
}
// WScript.Echo(str)return
// 建立 FSO
var fso = new ActiveXObject("Scripting.FileSystemObject")
// 创建文本文件
var file = fso.CreateTextFile("EX050310.txt", true)
// 将字符串写入文件
file.Write(str)
// 关闭文件流
file.Close()
delete file// 清理对象引用
delete fso
CollectGarbage()// 显式调用垃圾回收
}
printStar(5)
// 收集数字
function CollectDigits(s) {
return s.replace(/\D/g, "")
}
WScript.Echo(CollectDigits("1abc23def4"))