Copiar código del código de la siguiente manera:
String.prototype.trim = function () {
Devuelve this.replace (/(^/s*) | (/s*$)/g, "");
}
// Verifique si es el formato de fecha
function isDate (datestr) {
VAR result = datestr.match (/(^(((^(1 [8-9]/d {2}) | ([2-9]/d {3})) (-) (10 | 12 | 0 ? ([2-9]/d {3})) (-) (11 | 0? [469]) (-) (30 | [12] | 0? [1-9] $) | [8-9]/D {2}) | 0? [1-9]) $) | ) (0? 2) (-) (29) $) | 9] [0-9] [0] [48]) (-) (0? 2) (-) (29) $) | (0? 2) (-) (29) $) | 89] [13579] [26]) (-) (0? 2) (-) (29) $) | 2) (-) (29) $)/););););););););
if (result == null) {
Regresar "no";
}
Regresar "Sí";
}
// Este método es consistente con el efecto anterior anterior
Function isDate2 (datestr) {
VAR result = DatStr.Match (/^(/D {1,4}) (-| //) (/D {1,2})/2 (/D {1,2});
if (resultado == nulo)
Regresar "no";
var d = nueva fecha (resultado [1], resultado [3] -1, resultado [4]);
If ((d.getblyear () == resultado [1] && (d.getMonth () + 1) == resultado [3] && d.getDate () == resultado [4]) {) {) {) {
Regresar "Sí";
}
Regresar "no";
}
// Determinar si el carácter de entrada es chino
función ischina (str) {
if (str.length! = 0) {{
Reg =/^[/u0391-/uffe5]+$/;
if (! reg.test (str)) {
// alerta ("Lo siento, el formato de tipo de la cadena que ingresó es incorrecta!"););
Regresar "no";
}
}
Regresar "Sí";
}
// juzgar si está vacío
Función isEpty (str) {
if (str == null || typeof str == "Underfined" || str.trim () == "") {
Devolver verdadero;
} Demás {
Devolver falso;
}
}
// Teléfono fijo
Función testtelephone (teléfono) {{
Var phone_reg = new Regexp (/^([+] {0,1}/D {3,4} |/d {3,4}-)?/D {7,8} $/);
if (! phone_reg.test (teléfono)) {{
Regresar "no";
}
Regresar "Sí";
}
//Descuento
Function isDiscount (descuento) {
var phone_reg = new Regexp (/^(0 (/., D {1,2}) | 1 | 1.00 | 1.0);
if (! phine_reg.test (descuento)) {
Regresar "no";
}
Regresar "Sí";
}
//número de teléfono
Función testMobile (mobile) {
Var mobile_reg = new Regexp (/^0 {0,1} 1 [0-9] {10} $/);
if (! mobile_reg.test (mobile)) {
Regresar "no";
}
Regresar "Sí";
}
// El número QQ comienza desde 10000
Función testQq (qq) {
var qq_reg = new Regexp (/^[1-9] [0-9] {4,} $/);
if (! qq_reg.test (qq)) {
Regresar "no";
}
Regresar "Sí";
}
//correo electrónico
Función testmail (correo electrónico) {
var ageal_reg = new Regexp (/^/w+(bar-+.font>/w+)*@/w+(bar-.font>/w+)*./w+(bar-font>/w+)*$/);
if (! email_reg.test (correo electrónico)) {
Regresar "no";
}
Regresar "Sí";
}
// El entero positivo sin símbolos
Función testplusDigit (dígito) {
var plusdigit_reg = new Regexp (/^/D+$/);
if (! Plusdigit_reg.test (dígito)) {{
Regresar "no";
}
Regresar "Sí";
}
// precio doble
Function testPriceformat (str) {
Var PriceFormatReg = new Regexp (/^/d+(./ D {1,2})? $/);
if (! PriceFormatReg.test (str)) {
Regresar "no";
}
Regresar "Sí";
}
//Tarjeta de identificación
Función testIdCard (str) {
Var idcardreg = new RegXp (/(^/D {15} $) | (^/d {17} ([0-9] | x) $)/);
if (! idcardreg.test (str)) {
Regresar "no";
}
Regresar "Sí";
}
// Formato de fecha 2012-06-19
Función testDate (str) {
var dateg = new Regexp (/(^/D {4}-[0,1] [0-9]-[0-3] [0-9] $)/);
if (! DataReg.test (str)) {
Regresar "no";
}
Regresar "Sí";
}
// Operaciones precisas de recuento de puntos flotantes (método más)
Función acadd (arg1, arg2) {{
var r1, r2, m, n;
intente {r1 = arg1.ToString ().
intente {r2 = arg2.toString ().
m = Math.Pow (10, Math.max (R1, R2));
n = (r1> = r2)?
Return ((arg1*m+arg2*m)/m) .tofixed (n);
}
Número.prototype.add = function (arg) {
Regresar acadd (arg, esto);
}
// Conteo de puntos flotantes Operaciones precisas (resta)
Función acsub (arg1, arg2) {{
Return acadd (arg1, -arg2);
}
Número.prototype.subtract = function (arg) {
Cuenta de devolución (esta, arg);
}
// Conteo de puntos flotantes Operaciones precisas (método de multiplicación)
Función Accmul (Arg1, Arg2)
{{
Varm m = 0, s1 = arg1.ToString (), s2 = arg2.ToString ();
Intente {m+= s1.split (".") [1] .length} catch (e) {}
Prueba {m+= s2.split (".") [1] .length} catch (e) {}
Número de retorno (S1.replace (".", "")*Número (S2.replace (".", "") /Math.Pow (10, M)
}
Número.prototype.mul = function (arg) {
Devolver accmul (arg, esto);
}
// Recuento de puntos flotantes Operaciones precisas (divididas por método)
Función accDiv (arg1, arg2) {{
var t1 = 0, t2 = 0, r1, r2;
Prueba {t1 = arg1.ToString ().
intente {t2 = arg2.toString ().
con (matemáticas) {
R1 = número (arg1.ToString (). Reemplazar (".", ""))
r2 = número (arg2.ToString (). reemplazar (".", ""))
Return (r1/r2)*pow (10, t2-t1);
}
}
Número.prototype.div = function (arg) {
Devolver accdiv (this, arg);
}
// limitar los números de entrada
función isnumber (e) {
if ($ .browser.msie) {
If ((event.keycode> 47) && (event.keycode <58)) ||
(Event.keycode == 8)) {
Devolver verdadero;
} Demás {
Devolver falso;
}
} Demás {
if ((e.which> 47) && (E. which <58)) ||
(E. which == 8)) {) {
Devolver verdadero;
} Demás {
Devolver falso;
}
}
}
// Corte de longitud de cadena
Función CUTSTR (STR, LEN) {
prueba var;
var icount = 0;
var Patrn =/[^/x00-/xff]/;
var estrre = "" ;;
para (var i = 0; i <str.length; i ++) {
if (icount <Len -1) {
temp = str.substr (i, 1);
if (patrn.exec (temp) == null) {
icount = icount + 1;
} Demás {
icount = icount + 2;
}
strre += prueba;
} Demás {
Romper
}
}
Return strre + "..." ;;
}
// Obtener el host de nombre de dominio
Función gethost (url) {
var host = "null";
ifof url == "Underfined" ||
url = window.location.href;
}
var regex =/^/w+/: ////////////////////////////////// Kshmnalous
varming = url.match (regex);
if (typeof Match! = "Undefined" && null! = Match) {
host = Match [1];
}
Host de regreso;
}
// Determinar si un valor está en el área
// rang = 1 indica el entero positivo [0,2147483647] 2 indica flotación [0,3.4028235e38]
// return = 'vacía' significa que la entrada está vacía,
Función israng (str, rang) {
If (typeof str == "número") {{
var num = número (str);
// Determinar si está en el rango del entero positivo
if (right == 1) {
if (testplusDigit (num) == "sí") {{
if (num> = 0 && num <= 2147483647) {{
Return "is_int";
} Demás {
Return "is_not_int_rang";
}
} Demás {
Return "is_not_int";
}
} else if (rang == 2) {{
if (testPriceformat (num) == "sí") {{
if (num> = 0 && num <= 3.4028235e38) {
Return "is_float";
} Demás {
Return "is_not_float_rang";
}
} Demás {
Return "is_not_float";
}
} Demás {
Return "rang_is_not_right";
}
} Demás {
Return "is_not_number";
}
}