Check whether the form is legal, why can't use n++ discussion

Source: Internet
Author: User

Tag: The content button will determine how the input determines the user input to start

Do form processing, is generally to check the user input is legitimate, and then all legitimate output

So we have to face a problem, how to check is not all legal? How can I end the function of the submit button when it's not legal?

At first I proposed to define a variable n, and then the user input a data each time into the detection function, and then at the end of the function as long as the judgment passed on the n++;

Finally, it is only necessary to determine whether the value of n meets the demand value to determine whether the "submit" button is functioning.

However, I also found that this method is not good, although it is convenient, but always can not eliminate the user repeated input of the same data interference, if the user has entered a legitimate data, such as user name, has been repeated input, will lead to the value of n quickly reached the standard, which will not prevent "commit" button to perform the function.

Therefore, to detect whether the form is legitimate, or directly at the end of the detection function to return a true and false value, the last Commit button on the comprehensive judgment is not all function return is true, only the whole is real to work, there is a false stop function, so more stable and most reasonable.

Check whether the form is legal, why can't use n++ discussion

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.