js| data
These JS code are some of the form submitted in the code often used, most of the code is written with regular expressions!
Go to the left space;
function LTrim (s) {
Return S.replace (/^\s*/, "");
}
Go to the right space;
function RTrim (s) {
Return S.replace (/\s*$/, "");
}
Left and right space;
function Trim (s) {
return RTrim (LTrim (s));
}
is a null value;
function IsEmpty (_STR) {
var tmp_str = trim (_STR);
return tmp_str.length = = 0;
}
whether the effective email;
function IsMail (_STR) {
var tmp_str = trim (_STR);
var pattern =/^[_a-z0-9-]+ (. [ _a-z0-9-]+) *@[a-z0-9-]+ (. [ a-z0-9-]+) *$/;
Return Pattern.test (TMP_STR);
}
The number of valid figures;
function Isnumber (_STR) {
var tmp_str = trim (_STR);
var pattern =/^[0-9]/;
Return Pattern.test (TMP_STR);
}
Whether the color value is valid;
function IsColor (color) {
var Temp=color;
if (temp== "") return true;
if (temp.length!=7) return false;
Return (Temp.search (/\#[a-fa-f0-9]{6}/)!=-1);
}
Whether the link is valid;
function Isurl (URL) {
var stemp;
var b=true;
Stemp=url.substring (0,7);
Stemp=stemp.touppercase ();
if ((stemp!= "http://") | | (URL.LENGTH<10)) {
B=false;
}
return b;
}
Whether the cell phone number is valid;
function IsMobile (_STR) {
var tmp_str = trim (_STR);
var pattern =/13\d{9}/;
Return Pattern.test (TMP_STR);
}