/ * * --------------- Client Table Single CONQERY TECHNICAL CHECKFORM (Ofee) ----------------- * Function: General Verification All Form element. * Use: *
* * * * * * * * * * /
// Main function function checkform ({var els = = = lyments; // Traverse all table elements for (var i = 0; i Regular expression, not case sensitive varreg = new regexp (SREG, "I"); if (! Reg.test (sval)) {// Verification does not pass, pop-up prompt warning alert (ELS [i] .warning ); // The form element acquires the focus, uses a universal return function GOBACK (ELS [I]) Return False;}}}}}
/ / Universal Value Function is divided into three categories // text input box, directly values EL.Value // Single multi-selection, traverse all options acquire the number of selected numbers "00" indicates that two /// Single plummete menu, traversing all options acquired the number of selected numbers Returns "0" indicates the type of Function getValue (EL) {// Var style = el.Type; switch (stype) {casse "text ": Case" hidden ": case" password ": case" file ": case" textarea ": return el.value; Case" Checkbox ": Case" Radio ": Return GetValuechoose (EL); Case" Select-One ": Case "select-multiple": return getValueSel (EL);} // acquire radio, checkbox's selection, use "0" to indicate the number of selected numbers, we can pass 0 {1,} when we write Select a number of function getValuechoose (el) {var svalue = ""; // get the NAME of the first element, search this element group VAR TMPELS = Document.GtelementsByname (El.Name); for (var i = 0; i < TMPELS.LENGTH; I ) {IF (TmPels [i] .checked) {sValue = "0";}} Return Svalue;} // Get selected in SELECT, use "0" to represent the number of selected numbers, we When writing is correct, you can use 0 {1,} to indicate a number of function getValueSel (el) {var svalue = ""; for (var i = 0; i // General return function, verify that the effect is not returned. Take three types of value // text input box, the cursor is positioned in the end of the text input box // Single multi-selection, the first option acquisition focus // Single drop menu , Acquire FUNCTION GOBACK (EL) {// Type VAR Stype = El.Type; Switch (STYPE): Case "Hidden": Case "Password": Case "File": case " TEXTAREA ": El.focus (); var rng = el.createtextRange (); rng.collapse (false); rng.select (); Case" Checkbox ": Case" Radio ": var els = document.getElementsByName (el.) Name); ELS [0] .focus (); case "select-one": case "select-multiple": el.focus ();}} // check FieldFunction checkfield (file) {// Do you need to verify IF ( Field.check) {// Validated regular string var sag = field.check; // Get the value of the form, use universal values function var sval = getValue (field); // String -> Regular expression, Not case sensitive varreg = new regexp (SREG); if (! Reg.test (sval)) {// Verification is not passed, pop-up prompt warning alert (field.warning); // This form element achieves focus, with universal Return Function GOBACK (Field) Return false;}} return true;} attached: regular expression list
// General return function, verify that the effect is not returned. Take three types of value // text input box, the cursor is positioned in the end of the text input box // Single multi-selection, the first option acquisition focus // Single drop menu , Acquire FUNCTION GOBACK (EL) {// Type VAR Stype = El.Type; Switch (STYPE): Case "Hidden": Case "Password": Case "File": case " TEXTAREA ": El.focus (); var rng = el.createtextRange (); rng.collapse (false); rng.select (); Case" Checkbox ": Case" Radio ": var els = document.getElementsByName (el.) Name); ELS [0] .focus (); case "select-one": case "select-multiple": el.focus ();}} // check FieldFunction checkfield (file) {// Do you need to verify IF ( Field.check) {// Validated regular string var sag = field.check; // Get the value of the form, use universal values function var sval = getValue (field); // String -> Regular expression, Not case sensitive varreg = new regexp (SREG); if (! Reg.test (sval)) {// Verification is not passed, pop-up prompt warning alert (field.warning); // This form element achieves focus, with universal Return Function GOBACK (Field) Return false;}} return true;} attached: regular expression list