Parsley: How NOT to validate on certain events

229 views Asked by At

I want to trigger the parsley-error on an input text field only at the time of 'focus out' and not on change event.

These are the steps I perform to produce the issue:

  1. Enter some invalid characters in the text field. At this point of time, the parsley-error is not trigerred (OK, as per my requirements).
  2. When I tab-out of the field, the parsley-error is trigerred and I see the error on the tooltip of the text box (OK, as per my requirements).
  3. Now, when I again go back to the same text field and start entering some more characters, the parsley error is trigerred (This is the ISSUE).

I don't want the user to be bugged by the error appearing on the tooltip while he is making the changes. The error should be appeared only at the time of focus out but on this third step, the error is appearing at the time of 'change' as well.

I am not sure how can I tell Parsley to avoid some certain triggers! Any suggestion?

Please note that the issue is not faced on the first step. The issue is faced only at the 3rd step mentioned above. Here is my code:

<input type="text" class="form-control border-radius-6 onClickHideError"
                                        id="passport_number" name="passport_number" required=""
                                        maxlength="30"
                                        placeholder=""
                                        data-parsley-password-field="true"
                                        data-parsley-trigger="focusout"
                                        data-parsley-pattern="/^[a-zA-Z0-9]*$/"
                                        data-parsley-required-message="${commonRequiredMsg}"
                                        data-parsley-pattern-message="${passportInvalidMsg}"
                                        autocomplete="off">
1

There are 1 answers

1
Marc-André Lafortune On

Parsley allows you to set data-parsley-trigger-after-failure to your choosing.