Search code examples
jquery-validation-engine

How set class to input on error using jQuery-validation-engine


I'm using the jquery-validation-engine plugin and after validate I need to add a class to the inputs with the error promt to add for example a red border or something like that, is there a way using the plugin configuration to setup this?


Solution

  • I alsow use that same plugin.

    Do you have the last verion off the plug-in ? In the file: jquery.validationEngine.js

    you will find almost at the bottom:

    InvalidFields: [],
        onFieldSuccess: false,
        onFieldFailure: false,
        onSuccess: false,
        onFailure: false,
        addSuccessCssClassToField: false,
        addFailureCssClassToField: false,
    

    These are the 'master' settings for the options you are looking for. My current setup is like:

            InvalidFields: [],
        onFieldSuccess: true,
        onFieldFailure: true,
        onFormSuccess: false,
        onFormFailure: false,
        addSuccessCssClassToField: 'inputbox-success',
        addFailureCssClassToField: 'inputbox-error',
    

    And then the two css classes in youre css file ( 'inputbox-error' & 'inputbox-succes').

    This works just fine over here.. Good Luck...

    And if you have any more question about this plugin or other functions off it just ask .. :P

    Greets, Marco