S
S
Sergey Beresnev2011-02-14 06:55:12
PHP
Sergey Beresnev, 2011-02-14 06:55:12

Approach or implementation for form validation?

There are several forms, it is necessary to validate the data for each form separately. There are several problems:
How the validation should look like:
an optional field, but if it is filled, then it must meet a certain condition,
several optional fields, but at least one of them must be filled,
several optional fields, but if one of them is filled , then the rest must be filled in as well?
How should the composition of the previous paragraphs look like?
Or should you not bother with such flexibility and write special checks for such cases?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Arthur Koch, 2011-02-14
@dudeonthehorse

Do you have any idea what kind of headache you want to deliver to the user with a similar form?

an optional field, but if it is filled, then it must meet a certain condition,
several optional fields, but at least one of them must be filled,
several optional fields, but if one of them is filled, then the rest must be filled in?

How do you want to explain to the form filler the appropriateness of what to enter and what not to enter? Even if you can do this, most people will still be confused to say the least. Forms do not need such “flexibility”, everything should be simple and obvious. Merge fields, modernize the form for maximum simplicity.

C
Chvanikoff, 2011-02-14
@Chvanikoff

Take a look at the implementation of the validator in the Kohana 3 framework - I think it's a good example. You can implement a check if certain fields are filled in using callbacks, if I understand correctly what it is about.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question