An example of JavaScript integration verification method for web form

xiaoxiao2021-03-06  86

As a web designer, a CODER, is you tired of the form verification problem in the web design? Don't bother to copy if (x) {Alert ('WRONG');}, or use an unhappy and my intention Ide? Ok, let me tell you a comparison of Lazy's writing, you may not verify the form of the form ... Principle: Form verification is nothing more than to collect each message, that is, write one The JavaScript function named frmvalid, executing the following: ... if (to verify the entry is not in line with the condition) {Alert ('error!'); To be verified entry .focus (); return false;} ... // All right return true; of course,

//// function: frmvalid // ----------------- // Author hongz // usage: Yourform.οnsubmit =" Return frmvalid (this) " . // purpose: To Validate form elements in an integrated way.//function frMvalid (obj) {// ELEMENT S Array, Initialization for Validation Elems = New Array (New Array ('username ", // name of elements to be validated" value.length <1 || value.search (/ [^ a-za-z0-9 _] / )> = 0 ', // validation condition' invalid username: You can only enter a combination of 6-20 letters, numbers, underscores! '), // Prompt On Failure New Array (' Password ',' Value.Length <5 || Value.Search (/ [^ a-za-z0-9 _] /)> = 0 ',' invalid password: You can only enter a combination of 6-20 letters, numbers, and underscore! '

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

New Post(0)