jQuery UI Widgets › Forums › General Discussions › Plugins › Validator, Drag & Drop, Sortable › Validator rules' "action" attribute unclear
Tagged: jqxvalidator, validator
This topic contains 2 replies, has 2 voices, and was last updated by aorlic 13 years, 6 months ago.
-
Author
-
Hello!
I have trouble setting up validadors on my form.
A general problem is that it is not well documented – do you have a single place where ALL possible “actions” are listed and explained?
I have several concrete problems. Here is one of them… A text-input should be checked ONLY when user types something, so I used ‘keyup’:
rules: [ { input: '#npr_txt_alias', message: 'This field is mandatory', action: 'keyup', rule: 'required' }, { input: '#npr_txt_alias', message: 'Maximum lenght of this field is 10 characters', action: 'keyup', rule: 'maxLength=10' },.........However, the validator’s message appears as soon as this text-box gets the focus and before he types anything. As the field is initially empty – this annoying message appears each time user is on this form and before he even types something.
Can you please help me with this?
Thank you,
Aleks.
Hi Aleks,
The Validator’s documentation + rules can be found here: jquery-validator-api.htm. Action could be any JavaScript event. What we do it to bind the widget to be validated to the event which you set as ‘action’ and when the ‘action’ occurs(i.e the event is raised), we validate the input. If the validation passes, we do not show an alert, otherwise we show an alert.
From the above code, the validation message will be displayed on Key Up event if the Input is empty or is less than 10 characters.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comThank you Peter.
From the above code, the validation message will be displayed on Key Up event if the Input is empty or is less than 10 characters.
That’s the problem – the validation message is shown also when the control obtains the focus (and is empty or has <10 chars of course). This is wrong, since it’s not ‘onkeyup’, but ‘onfocus’ event. Maybe this is a bug?
-
AuthorPosts
You must be logged in to reply to this topic.