jQWidgets Forums

jQuery UI Widgets Forums Plugins Validator, Drag & Drop, Sortable Validator rules' "action" attribute unclear

This topic contains 2 replies, has 2 voices, and was last updated by  aorlic 12 years, 3 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author

  • aorlic
    Member

    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.


    Peter Stoev
    Keymaster

    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 Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    aorlic
    Member

    Thank 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?

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.