java浮点数没有负数吗_是否规定的浮点数

//是否规定的浮点数,包括小数点前的位数和小数点后的位数,beforeDec是小数点前的位数,afterDec是小数点后的为数functioncheckDecimalNumber(theField, fieldName, beforeDec, afterDec){if(theField.value=="")returntrue;varpattern="/^(|[+-]?(0|([1-9]\\d{0,"+(beforeDec-1)+"})|((0|([1-9]\\d{0,"+(beforeDec-1)+"}))?\\.\\d{1,"+afterDec+"})){1,1})$/";if(!eval(pattern).test(theField.value)) {

alert(fieldName+"必须为合法数字,允许小数点前"+beforeDec+"位和小数点后"+afterDec+"位之内");

theField.focus();

theField.select();returnfalse;

}returntrue;

}//使用 prototype 为 String 对象增加一个新方法 length2,找出字符串中有多少个汉字,然后将这个数字加上 length 的值就是我们想要的结果了。String.prototype.length2=function() {varcArr=this.match(/[^\x00-\xff]/ig);returnthis.length+(cArr==null?0: cArr.length);

}//限制字串最大长度functioncheckLength(theField, fieldName, maxLength) {if(theField.value=="")returntrue;if(theField.value.length2()>maxLength) {

alert(fieldName+"的字数最多为"+maxLength+"字!");

theField.select();

theField.focus();returnfalse;

}returntrue;

}//限制字串长度,注意参数顺序functioncheckLength2(theField, fieldName, maxLength, minLength) {if(theField.value=="")returntrue;if(theField.value.length2()>maxLength) {

alert(fieldName+"的字数最多为"+maxLength+"字!");

theField.focus();returnfalse;

}if((minLength!="")&&(theField.value.length2()

alert(fieldName+"的字数最少为"+minLength+"字!");

theField.focus();returnfalse;

}returntrue;

}//所输入字符串是否均为合法字符//charBag中为包含所有合法字符的字符串functioncheckStrLegal(theField, fieldName, charBag) {if(theField.value=="")returntrue;for(vari=0; i

alert(fieldName+"含有非法字符("+c+")!");

theField.focus();returnfalse;

}

}returntrue;

}//所输入字符串是否均为合法字符//charBag中为包含非法字符的字符串functioncheckStrLegal2(theField, fieldName, charBag) {if(theField.value=="")returntrue;for(vari=0; i-1) {

alert(fieldName+"含有非法字符("+c+")!");

theField.focus();returnfalse;

}

}returntrue;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值