Page anti-stay

xiaoxiao2021-03-06  89

/ / Whether it is an integer

Function isinteger (Obj, title)

{

VAR TMP = PARSEINT (OBJ.VALUE)

IF (Isnan (TMP))

{

Alert (Title ": You must enter an integer!");

Obj.focus ();

Return False

}

Else if (tmp.tostring () == Obj.value)

{

Return True

}

Else

{

Alert (Title ": You must enter an integer!");

Obj.focus ();

Return False;

}

}

// Is it a null value?

Function isfill (Obj, title)

{

IF (Obj.Value.Length == 0)

{

Alert (Title ": Can't empty!");

Obj.focus ();

Return False;

}

Return True;

}

/ / Do you choose the content in the drop-down box

Function isddlselected (Obj, title)

{

IF (Obj.selectedIndex == 0)

{

Alert (Title ": Unselected!");

Return False;

}

Return True;

}

/ / Whether is Chinese

Function ischinese (Obj, title)

{

For (i = 0; i

{

IF (Obj.Value.Charcodeat (i) <10000)

{

Alert (Title ": You must enter Chinese!");

Obj.focus ();

Return False;

}

}

Return True;

}

/ / Is it a string of English?

Function Isenglishword (Obj, Title)

{

Var checken;

Var i;

Var J;

For (i = 0; i

{

Checken = Obj.value.charcodeat (i);

IF ((Checken> = 65 && checken <= 90) || (checken> = 97 && checken <= 122)))

{

}

Else

{

Alert (Title ": Only 26 letters!");

Obj.focus ();

Return False;

}

}

Return True;

}

/ / Is it a number of numbers?

Function ISEWORDNUMBERANDOTHER (OBJ, TITLE)

{

Var checken;

Var i;

Var J;

For (i = 0; i

{

Checken = Obj.value.charcodeat (i);

IF ((Checken> = 48 && checken <= 57) || (checken> = 65 && checken <= 90) || (Checken> = 97 && checken <= 122) || (Checken == 95))

{

}

Else

{

Alert (Title ": can only contain numbers, letters and underscores!");

Obj.focus (); Return False;

}

}

Return True;

}

Function isnumber (Obj, title)

{

Var letters = "1234567890";

VAR I, C;

For (i = 0; i

{

C = obj.value.Charat (i);

IF (letters.indexof (c) <0)

{

Alert (Title ": must be a number!");

Obj.focus ();

Return False;

}

}

Return True;

}

/ / Whether it is a number

Function isdecimal (Obj, title)

{

Var letters = "1234567890."

Var i;

Var C;

For (i = 0; i

{

C = obj.value.Charat (i);

IF (letters.indexof (c) <0)

{

Alert (Title ": must be a number!");

Obj.focus ();

Return False;

}

}

Return True;

}

/ / Whether it is a string for email format

Function ISEMAILFORMAT (OBJ, TITLE)

{

Var emailstr = obj.value;

// var emailpat=/^(. )@( (. ) $/;

Var emailpat = // w ([- .] / w ) * @ / w ([-.] / w ) * /. / w ([-.] / w ) * /;

Var matcharray = emailstr.match (emailpat);

IF (Obj.Value.Length! = 0 && matchay == NULL)

{

Alert (Title ": Email Format Error!");

Obj.focus ();

Return False;

}

IF (Obj.Value.Length! == 0)

{

VAR ncount1 = 0;

For (i = 1; i <= obj.value.Length; i )

{

VAR D = Obj.Value.substring (i-1, i);

IF (d == '@')

{

NCOUNT1 ;

}

}

IF (ncount1! = 1)

{

Alert (Title "cannot enter two '@'");

Return False;

}

}

Return True;

}

// Shield Right Button and Status

Function NocontextMenu ()

{

Event.cancelbubble = TRUE

Event.ReturnValue = false;

Return False;

}

Function NorightClick (e)

{

IF (window.event)

{

IF (E.WHICH == 2 || E.Which == 3)

Return False;

}

Else if (event.button == 2 || Event.Button == 3)

{

Event.cancelbubble = truevent.ReturnValue = false;

Return False;

}

}

Function ClearrightClickAndStatus ()

{

WINDOW.STATUS = "Welcome to the Information Management System";

IF (window.event)

Document.captureEvents (Event.Mouseup);

Document.onContextMenu = NocontextMenu; // for IE5

Document.onmousedown = norightclick; // for all others

}

Var strold = new string;

Function ChangeStyle (O)

{

Var str = new string;

Str = o.value;

IF (str == "")

{

o.value = "0";

Return;

}

Var infindex = str.indexof (",");

While (intIndex! = - 1)

{

Str = str.replace (",", ");

INTINDEX = Str.indexof (",");

}

IF (isnan (STR) == false

{

IF (o.value.charat (0) == "-")

{

Alert ('annual fee input is incorrect!');

O.focus ();

}

Else

{

Str = math.Round (str * 100) / 100

o.value = convert (STR)

}

}

Else

{

Alert ('annual fee can only enter digital!');

O.focus ();

}

}

Function Convert (NUM)

{

Var strnum = "" NUM;

Var arrnum = strnum.split (".");

Try

{

Var str = arrnum [0];

Var len = str.length;

Var Cornum;

IF (len% 3 == 0) Cornum = PARSEINT (LEN / 3) -1;

Else Cornum = PARSEINT (LEN / 3);

VAR TEMP = "";

For (var i = 0; i <= cornum; i )

{

IF (i == 0)

{

Temp = Strnum.Substring (LEN-3, LEN);

}

Else IF (i 0)

{

Temp = Strnum.Substring (LEN-3 * (i 1), LEN-3 * i) "," TEMP

}

Else

{

Temp = strnum.substring (LEN-3 * (i 1), LEN-3 * I) "," TEMP;

}

}

IF (Arrnum.length> 1) TEMP = "." arrnum [arrnum.length-1];

Return Temp;

}

Catch (e)

{

Alert (E.MESSAGE);

}

}

Function RemoveComma (O)

{

IF (O.Readonly == True) Return 0;

Var str = new string;

Str = o.value;

Strold = o.value;

Var infindex = str.indexof (",");

While (intIndex! = - 1)

{

Str = str.replace (",", ");

INTINDEX = Str.indexof (",");

}

O.value = STR;

Var e = esent.srcelement;

Var r = E.CREATETEXTRANGE ();

R.MoveStart ('Character', E.Value.Length);

R.Collapse (True);

R.select ();

}

转载请注明原文地址:https://www.9cbs.com/read-95652.html

New Post(0)