Passing dependency-callback to Validation `required`

Support General Passing dependency-callback to Validation `required`Resolved

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #24803
    Austin PassyAustin Passy
    Participant

    According to the docs for jQuery Validation: https://jqueryvalidation.org/required-method/ you can pass a dependency-callback which returns a boolean value on condition. I am aware from PHP passing the validations rules array gets JSON encoded. So the final output would look something like {"rules":{"programs":{"required":"function() { return $('#taxonomy').val() != '224' }"}}}

    It would be great to add a feature to process the encoded script data and check for some kind of format prefix to convert to JS.

    I've seen some examples out there, but haven't tested or validating any thoroughly. Just adding in some feedback, without having to implement my own validation script.

    #24807
    Long NguyenLong Nguyen
    Moderator

    Hi Austin,

    The Validation also supports remote setting. You can use it to validate the input value with your own PHP function. It only accepts returned value true/false.
    https://docs.metabox.io/validation/#validation-with-jquery-validation-plugin

    Refer to this topic https://support.metabox.io/topic/validation-for-data-uniqueness/.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.