// Function Name: trim
// Function Description: Remove leading and trailing spaces from the string
// Creation Date: 2004-7-13 15:30
// Last Modify By: N/A
// Last Modify Date: N/A
String.prototype.trim=function(){
return this.replace(/(^s*)|(s*$)/g, "") ;
}
// Function Name: ltrim
// Function Description: Remove the spaces on the left side of the string
// Creation Date: 2004-7 -13 9:58
// Last Modify By: N/A
// Last Modify Date: N/A
String.prototype.ltrim=function()
{
return this .replace(/(^s*)/g, "");
}
// Function Name: rtrim
// Function Description: Remove the spaces on the right side of the string
// Creation Date: 2004-7-13 15:31
// Last Modify By: N/A
// Last Modify Date: N/A
String.prototype.rtrim=function()
{
return this.replace(/(s*$)/g, "");
}
// Function Name: len
// Function Description: Return The actual length of the string, one Chinese character counts as 2 lengths
// Creation Date: 2004-7-13 9:58
// Last Modify By: N/A
// Last Modify Date: N /A
String.prototype.len=function()
{
var str=this;
return str.replace(/[^x00-xff]/g, "**"). length
}
// Function Name: isValidDate
// Function Description: Determine whether the input is a valid short date format - "YYYY-MM-DD"
// Creation Date: 2004-7-13 9:58
// Last Modify By: N/A
// Last Modify Date: N/A
String.prototype.isValidDate=function()
{
var result=this.match(/^(d{1,4})(-|/)(d{1,2})2(d{1,2})$/);
if(result ==null) return false;
var d=new Date(result[1], result[3]-1, result[4]);
return (d.getFullYear()==result[1] &&d.getMonth() 1==result[3]&&d.getDate()==result[4]);
}
// Function Name: isValidTime
// Function Description: Judgment Whether the input is a valid time format - "HH:MM:SS"
// Creation Date: 2004-7-13 9:58
// Last Modify By: N/A
// Last Modify Date: N/A
String.prototype.isValidTime=function()
{
var resule=this.match(/^(d{1,2})(:)?(d{1, 2})2(d{1,2})$/);
if (result==null) return false;
if (result[1]>24 || result[3]>60 || result[4]>60) return false;
return true;
}
// Function Name: isValidEmail
// Function Description: Determine whether the input is a valid email
// Creation Date: 2004-7-13 9:59
// Last Modify By: N/A
// Last Modify Date: N/A
String.prototype.isValidEmail=function()
{
var result=this.match(/^w ((-w )|(.w ))*@[A-Za-z0-9] ((.|-)[A-Za- z0-9] )*.[A-Za-z0-9] $/);
if(result==null) return false;
return true;
}
/ / Function Name: isValidDatetime
// Function Description: Determine whether the input is a valid long date format - "YYYY-MM-DD HH:MM:SS"
// Creation Date: 2004-7-13 9: 59
// Last Modify By: N/A
// Last Modify Date: N/A
String.prototype.isValidDatetime=function()
{
var result=this.match (/^(d{1,4})(-|/)(d{1,2})2(d{1,2}) (d{1,2}):(d{1,2}) :(d{1,2})$/);
if(result==null) return false;
var d= new Date(result[1], result[3]-1, result[4 ], result[5], result[6], result[7]);
return (d.getFullYear()==result[1]&&(d.getMonth() 1)==result[3]&&d .getDate()==result[4]&&d.getHours()==result[5]&&d.getMinutes()==result[6]&&d.getSeconds()==result[7]);
}
// Function Name: isValidInteger
// Function Description: Determine whether the input is an integer
// Creation Date: 2004-7-13 10:01
// Last Modify By: N/A
// Last Modify Date: N/A
String.prototype.isValidInteger=function()
{
var result=this.match(/^(-| )?d $ /);
if(result==null) return false;
return true;
}
// Function Name: isValidPositiveInteger
// Function Description: Determine whether the input is A positive integer
// Creation Date: 2004-7-13 10:01
// Last Modify By: N/A
// Last Modify Date: N/A
String.prototype. isValidPositiveInteger=function()
{
var result=this.match(/^d $/);
if(result==null) return false;
if(parseInt(this)>0 ) return true;
return false;
}
// Function Name: isValidNegativeInteger
// Function Description: Determine whether the input is a negative integer
// Creation Date: 2004 -7-13 10:28
// Last Modify By: N/A
// Last Modify Date: N/A
String.prototype.isValidNegativeInteger=function()
{
var result=this.match(/^-d $/);
if(result==null) return false;
return true;
}
// Function Name: isValidNumber
// Function Description: Determine whether the input is a number
// Creation Date: 2004-7-13 10:01
// Last Modify By: N/A
// Last Modify Date : N/A
String.prototype.isValidNumber=function()
{
return !isNaN(this);
}
// Function Name: isValidLetters
// Function Description: Determine whether the input is a string consisting of A-Z / a-z
// Creation Date: 2004-7-13 10:10
// Last Modify By: N/A
// Last Modify Date: N/A
String.prototype.isValidLetters=function()
{
var result=this.match(/ ^[a-zA-Z] $/);
if(result==null) return false;
return true;
}
// Function Name: isValidDigits
// Function Description: Determine whether the input is a number composed of 0-9
// Creation Date: 2004-7-13 10:10
// Last Modify By: N/A
// Last Modify Date: N/A
String.prototype.isValidDigits=function()
{
var result=this.match(/^[1-9][0-9] $/);
if(result==null) return false;
return true;
}
// Function Name: isValidAlphanumeric
// Function Description: Determine whether the input is a 0- 9 / A-Z / a-z string
// Creation Date: 2004-7-13 10:14
// Last Modify By: N/A
// Last Modify Date: N/A
String.prototype.isValidAlphanumeric=function()
{
var result=this.match(/^[a-zA-Z0-9] $/);
if(result==null) return false;
return true;
}
// Function Name: isValidString
// Function Description: Determine whether the input is a string consisting of 0-9 / A-Z / a-z / . / _ Composed string
// Creation Date: 2004-7-13 10:20
// Last Modify By: N/A
// Last Modify Date: N/A
String.prototype .isValidString=function()
{
var result=this.match(/^[a-zA-Z0-9s.-_] $/);
if(result==null) return false ;
return true;
}
// Function Name: isValidPostalcode
// Function Description: Determine whether the input is a valid postal code
// Creation Date: 2004- 7-13 10:22
// Last Modify By: N/A
// Last Modify Date: N/A
String.prototype.isValidPostalcode=function()
{
var result=this.match(/(^[0-9]{6}$)/);
if(result==null) return false;
return true;
}
// Function Name: isValidPhoneNo
// Function Description: Determine whether the input is a valid phone number
// Creation Date: 2004-7-13 10:22
// Last Modify By: N /A
// Last Modify Date: N/A
String.prototype.isValidPhoneNo=function()
{
var result=this.match(/(^[0-9]{3 ,4}-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^([0-9]{3,4})[0-9 ]{3,8}$)/);
if(result==null) return false;
return true;
}
// Function Name: isValidMobileNo
/ / Function Description: Determine whether the input is a valid mobile phone number
// Creation Date: 2004-7-13 10:23
// Last Modify By: N/A
// Last Modify Date: N/A
String.prototype.isValidMobileNo=function()
{
var result=this.match(/(^0{0,1}13[0-9]{9}$)/ );
if(result==null) return false;
return true;
}