[SOLVED] Validate inputs using QValidator class
-
Hello I am developing application which have many forms. I need to validate user input. I figure out QValidator is good solution for this. but I have many classes which has different forms. It is possible to use one QValidator class to validate all forms. Or I have to create QValidator object for every single input.
-
Hi
QValidator is (often) per Input
but you can share one validator with more than one input
if they have the same rules for acceptable input.But you cannot use one validator for a whole form since it has no way of knowing
which rules for each input.The easiest way to set validation up, really depends on what types of input you have and how different they are.
-
Hi
The validator work while user writes something so its hard to make it check for empty string so
maybe just check that on "OK".For phone and email, you can use RegExpValidator.
Please see
http://stackoverflow.com/questions/9101887/how-to-validate-email-address-using-qregexpIts a bit complex to start with but once you get it up and running, you can just reuse the validator where needed.