Next
3. Check whether the input in the JS verification text box is empty and whether the input is in digital format.
Implementation idea: according to the user's requirements, we need to click the submit button to verify whether all required items are empty and whether some numbers are in numeric format at one time, in addition, the verification prompt should be prompted in a uniform text in one place, and the pop-up window cannot be used. In addition, to avoid repeated work, we want to put all the page prompts in a method of a JS file, so that all the pages only need to call this method to implement the verification function. The final method we use is to judge twice. First, determine whether a control object exists on the page to be verified. If so, determine whether it is null or the format is correct.
Next we will verify the JSCodeShare with you:
// Determine whether the mobile phone number is empty, whether it is a number, and whether it is less than 11 bits var objapplicantcell = Document. getelementbyid ("applicantcell") if (objapplicantcell! = NULL) {var cellnum = document. getelementbyid ("applicantcell "). valueif (cellnum = "") {document. getelementbyid ("flag "). value = "the mobile phone number cannot be blank"; formflag. applicantcell. focus (); Return false;} var STRP =/^ \ D + $/; // If (! STRP. test (cellnum) {document. getelementbyid ("flag "). value = "the mobile phone number is not in digital format"; form1.applicantcell. focus (); Return false;} If (cellnum. length <11) {document. getelementbyid ("flag "). value = "mobile phone number cannot be less than 11 characters"; formflag. applicantcell. focus (); Return false ;}}
This code is used to verify the mobile phone number in one method. Other text boxes can also be used to verify similar writing methods. You can also use this code as a public method to call parameter passing.
Learning Through engineering can not only bring us motivation and interest in learning, but also enhance our self-confidence. With confidence, we will increase our desire to study in depth, in this way, we don't have to worry about any technology that we don't know. As long as you have the motivation to learn, learning technology is just a matter of time.