guillaumepotier / Parsley.js

Validate your forms, frontend, without writing a single line of javascript
http://parsleyjs.org
MIT License
9.05k stars 1.32k forks source link

How to exclude field from validation ? #1370

Closed MROALI closed 1 year ago

MROALI commented 1 year ago

Hello, i have a multistep form, and i need to exclude on fly some field depending on some critrerias...

I tried to implement field:validate , but not working. Do you have anyidea how can i do it, any idea ?

Parsley.on("field:validate", function(field) {
    var objField = field.$element
    if(!isFieldToValidate(objField)){
          objField.attr("data-parsley-excluded","true");
        return false;  
    }
    return true;
});
marcandre commented 1 year ago

Interdependencies are not super easy to handle. See this example and #949.

Good luck.