Question

I added a custom "func" validation rule specified below

"requiredPrice": { 
     "func": function (field, rules) {
         return (field.val() && field.val() != '')
     },
     "alertText": "* Price is required"
}

and added appropriate class in html

<input class="validate[custom[requiredPrice]]" type="text" id="fixed-price" data-   bind="value: PriceFixed" readonly="readonly" />

validation function returns false if value is empty, but

modifyLineForm.validationEngine('validate'); 

still returns true

Was it helpful?

Solution 2

In JQuery Validation Engine 2.6.2 there is a bug relates with using functions in validation rules, so even demo provided by developers doesn't work.

Fortunately in my particular case i just needed to change default message for "required" validation rule for some controls, so I decided to use "custom_error_messages".

Html:

<input class="validate[required] price" type="text" id="fixed-price" data-   bind="value: PriceFixed" readonly="readonly" />

JavaScript:

$('#modify-line-form').validationEngine({
        'custom_error_messages': {
            '.price': {
                'required': {
                    'message': "* Price is required"
                },

            }
        }
    });

OTHER TIPS

This is my guess out of the blue. Please try to use this instead.

class="validate[funcCall[requiredPrice]]"

For more details, please refer to: http://posabsolute.github.io/jQuery-Validation-Engine/#validators/funccall-methodname

Thanks!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top