Whether it is a dynamic website, or other B / S structure, it is not inseparable from the form of the form to the server to submit the data to the server to submit a considerable role. This will lead to a problem, is it legal? The problem in front of us is to verify that the data submitted by these data is legal. So, we wrote a big pile of verification functions. When we started the development of a new project, we have to write a lot of verification. Function, then debug this large number of functions ...
This article will introduce a method to improve my credibility and improve our development efficiency.
Personally think that the verification of the form should contain two parts: First, determine whether the data entered by the user is legal. Second, prompting that the user is not legal.
Therefore, our generic form verification function to be implemented is: First, obtain the data GetValue (EL) of the user input, verify the user's data checkform (OFORM) IE supports custom properties, this is this universal function. Based we can add the properties of your own information on the form element. It is a bit like XML .check property: This property is used to store the regular expression of the data legitimacy. Warning property: This property is used to store error prompt information. Third, return incorrect form Tips Goback (EL) The trigger event of these three steps is onSubmit, remember that return checkform (this) is wrong, it is full of fullness:)