var reg =
new RegExp(
'^[^\\\\\\/----:*?\\"<>|]+$');
alert(reg.test(
"新建文件\\夹"));
function checkMobile(s){
var regu =
/^1[3|4|5|7|8]\d{9}$/;
var re =
new RegExp(regu);
if (re.test(s)) {
return true;
}
else{
return false;
}
}
function telephone(str){
var regu=
/^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$|(^(13[0-9]|15[0|3|6|7|8|9]|18[8|9])\d{8}$)/;
var re =
new RegExp(regu)
if(!re.test(str))
{
alert(
"请输入正确的电话号码,\n\n如:0591-6487256,15005059587");
return false;
}
}
function checkCard(str) {
var arg1 =
/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/;
var arg2 =
/^[1-9][1-9][0-9]\d{3}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
if (str.match(arg1) ==
null && str.match(arg2) ==
null) {
return false;
}
else {
return true;
}
}
function checkQuote(str) {
var items =
new Array(
"~",
"`",
"!",
"@",
"#",
"$",
"%",
"^",
"&",
"*",
"{",
"}",
"[",
"]",
"(",
")");
items.push(
":",
";",
"'",
"|",
"\\",
"<",
">",
"?",
"/",
"<<",
">>",
"||",
"//");
items.push(
"admin",
"administrators",
"administrator",
"管理员",
"系统管理员");
items.push(
"select",
"delete",
"update",
"insert",
"create",
"drop",
"alter",
"trancate");
str = str.toLowerCase();
for (
var i =
0; i < items.length; i++) {
if (str.indexOf(items[i]) >=
0) {
return true;
}
}
return false;
}
function checkURL(str) {
if (str.match(
/(http[s]?|ftp):\/\/[^\/\.]+?\..+\w$/i) ==
null) {
return false
}
else {
return true;
}
}
function checkPhone(strPhone) {
var phoneRegWithArea =
/^[0][1-9]{2,3}-[0-9]{5,10}$/;
var phoneRegNoArea =
/^[1-9]{1}[0-9]{5,8}$/;
if (strPhone.length >
9) {
if (phoneRegWithArea.test(strPhone)) {
return true;
}
else {
return false;
}
}
else {
if (phoneRegNoArea.test(strPhone)) {
return true;
}
else {
return false;
}
}
}
function checkBankAccount(s){
var regu =
/^(998801|998802|622525|622526|435744|435745|483536|528020|526855|622156|622155|356869|531659|622157|627066|627067|627068|627069|621226)\d{13}$/;
var re =
new RegExp(regu);
if (re.test(s)) {
return true;
}
else{
return false;
}
}
function isIP(strIP) {
if (isNull(strIP))
return false;
var re=
/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/g
if(re.test(strIP))
{
if(
RegExp.$
1 <
256 &&
RegExp.$
2<
256 &&
RegExp.$
3<
256 &&
RegExp.$
4<
256)
return true;
}
return false;
}
function isNull( str ){
if ( str ==
"" )
return true;
var regu =
"^[ ]+$";
var re =
new RegExp(regu);
return re.test(str);
}
function isInteger( str ){
var regu =
/^[-]{0,1}[0-9]{1,}$/;
return regu.test(str);
}
function isNumber( s ){
var regu =
"^[0-9]+$";
var re =
new RegExp(regu);
if (s.search(re) != -
1) {
return true;
}
else {
return false;
}
}
function isDecimal( str ){
if(isInteger(str))
return true;
var re =
/^[-]{0,1}(\d+)[\.]+(\d+)$/;
if (re.test(str)) {
if(
RegExp.$
1==
0&&
RegExp.$
2==
0)
return false;
return true;
}
else {
return false;
}
}
function isPort( str ){
return (isNumber(str) && str<
65536);
}
function isEmail( str ){
var myReg =
/^[-_A-Za-z0-9]+@([_A-Za-z0-9]+\.)+[A-Za-z0-9]{2,3}$/;
if(myReg.test(str))
return true;
return false;
}
function isMoney( s ){
var regu =
"^[0-9]+[\.][0-9]{0,3}$";
var re =
new RegExp(regu);
if (re.test(s)) {
return true;
}
else {
return false;
}
}
function isNumberOr_Letter( s ){
var regu =
"^[0-9a-zA-Z\_]+$";
var re =
new RegExp(regu);
if (re.test(s)) {
return true;
}
else{
return false;
}
}
function isNumberOrLetter( s ){
var regu =
"^[0-9a-zA-Z]+$";
var re =
new RegExp(regu);
if (re.test(s)) {
return true;
}
else{
return false;
}
}
function isChinaOrNumbOrLett( s ){
var regu =
"^[0-9a-zA-Z\u4e00-\u9fa5]+$";
var re =
new RegExp(regu);
if (re.test(s)) {
return true;
}
else{
return false;
}
}
function isDate( date, fmt ) {
if (fmt==
null) fmt=
"yyyyMMdd";
var yIndex = fmt.indexOf(
"yyyy");
if(yIndex==-
1)
return false;
var year = date.substring(yIndex,yIndex+
4);
var mIndex = fmt.indexOf(
"MM");
if(mIndex==-
1)
return false;
var month = date.substring(mIndex,mIndex+
2);
var dIndex = fmt.indexOf(
"dd");
if(dIndex==-
1)
return false;
var day = date.substring(dIndex,dIndex+
2);
if(!isNumber(year)||year>
"2100" || year<
"1900")
return false;
if(!isNumber(month)||month>
"12" || month<
"01")
return false;
if(day>getMaxDay(year,month) || day<
"01")
return false;
return true;
}
function getMaxDay(year,month) {
if(month==
4||month==
6||month==
9||month==
11)
return "30";
if(month==
2)
if(year%
4==
0&&year%
100!=
0 || year%
400==
0)
return "29";
else
return "28";
return "31";
}
function isLastMatch(str1,str2)
{
var index = str1.lastIndexOf(str2);
if(str1.length==index+str2.length)
return true;
return false;
}
function isFirstMatch(str1,str2)
{
var index = str1.indexOf(str2);
if(index==
0)
return true;
return false;
}
function isMatch(str1,str2)
{
var index = str1.indexOf(str2);
if(index==-
1)
return false;
return true;
}
function checkTwoDate( startDate,endDate ) {
if( !isDate(startDate) ) {
alert(
"起始日期不正确!");
return false;
}
else if( !isDate(endDate) ) {
alert(
"终止日期不正确!");
return false;
}
else if( startDate > endDate ) {
alert(
"起始日期不能大于终止日期!");
return false;
}
return true;
}
function checkEmail(strEmail) {
var emailReg =
/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
if( emailReg.test(strEmail) ){
return true;
}
else{
alert(
"您输入的Email地址格式不正确!");
return false;
}
}
function checkSelect( checkboxID ) {
var check =
0;
var i=
0;
if( document.all(checkboxID).length >
0 ) {
for( i=
0; i<document.all(checkboxID).length; i++ ) {
if( document.all(checkboxID).item( i ).checked ) {
check +=
1;
}
}
}
else{
if( document.all(checkboxID).checked )
check =
1;
}
return check;
}
function getTotalBytes(varField) {
if(varField ==
null)
return -
1;
var totalCount =
0;
for (i =
0; i< varField.value.length; i++) {
if (varField.value.charCodeAt(i) >
127)
totalCount +=
2;
else
totalCount++ ;
}
return totalCount;
}
function getFirstSelectedValue( checkboxID ){
var value =
null;
var i=
0;
if( document.all(checkboxID).length >
0 ){
for( i=
0; i<document.all(checkboxID).length; i++ ){
if( document.all(checkboxID).item( i ).checked ){
value = document.all(checkboxID).item(i).value;
break;
}
}
}
else {
if( document.all(checkboxID).checked )
value = document.all(checkboxID).value;
}
return value;
}
function getFirstSelectedIndex( checkboxID ){
var value = -
2;
var i=
0;
if( document.all(checkboxID).length >
0 ){
for( i=
0; i<document.all(checkboxID).length; i++ ) {
if( document.all(checkboxID).item( i ).checked ) {
value = i;
break;
}
}
}
else {
if( document.all(checkboxID).checked )
value = -
1;
}
return value;
}
function selectAll( checkboxID,status ){
if( document.all(checkboxID) ==
null)
return;
if( document.all(checkboxID).length >
0 ){
for( i=
0; i<document.all(checkboxID).length; i++ ){
document.all(checkboxID).item( i ).checked = status;
}
}
else {
document.all(checkboxID).checked = status;
}
}
function selectInverse( checkboxID ) {
if( document.all(checkboxID) ==
null)
return;
if( document.all(checkboxID).length >
0 ) {
for( i=
0; i<document.all(checkboxID).length; i++ ) {
document.all(checkboxID).item( i ).checked = !document.all(checkboxID).item( i ).checked;
}
}
else {
document.all(checkboxID).checked = !document.all(checkboxID).checked;
}
}
function checkDate( value ) {
if(value==
'')
return true;
if(value.length!=
8 || !isNumber(value))
return false;
var year = value.substring(
0,
4);
if(year>
"2100" || year<
"1900")
return false;
var month = value.substring(
4,
6);
if(month>
"12" || month<
"01")
return false;
var day = value.substring(
6,
8);
if(day>getMaxDay(year,month) || day<
"01")
return false;
return true;
}
function checkPeriod( startDate,endDate ) {
if( !checkDate(startDate) ) {
alert(
"起始日期不正确!");
return false;
}
else if( !checkDate(endDate) ) {
alert(
"终止日期不正确!");
return false;
}
else if( startDate > endDate ) {
alert(
"起始日期不能大于终止日期!");
return false;
}
return true;
}
function checkSecCode( secCode ) {
if( secCode.length !=
6 ){
alert(
"证券代码长度应该为6位");
return false;
}
if(!isNumber( secCode ) ){
alert(
"证券代码只能包含数字");
return false;
}
return true;
}
function cTrim(sInputString,iType)
{
var sTmpStr =
' ';
var i = -
1;
if(iType ==
0 || iType ==
1)
{
while(sTmpStr ==
' ')
{
++i;
sTmpStr = sInputString.substr(i,
1);
}
sInputString = sInputString.substring(i);
}
if(iType ==
0 || iType ==
2)
{
sTmpStr =
' ';
i = sInputString.length;
while(sTmpStr ==
' ')
{
--i;
sTmpStr = sInputString.substr(i,
1);
}
sInputString = sInputString.substring(
0,i+
1);
}
return sInputString;
}
var test1 =
'1234567890'
var format = test1.replace(
/\B(?=(\d{3})+(?!\d))/g,
',')
console.log(format)
转载请注明原文地址: https://ju.6miu.com/read-24046.html