dimanche 10 juillet 2016

How to specify custom invalid condition in jquery validation engine?

I have two select boxes each with some values I want to validate for condition that, if value Value 1 is greater than value in Value 2 then the error prompt should show and the form should NOT submit. This is the code $(document).ready(function(){ $("#formid1").validationEngine('attach'); }); function testfunc(value1id, value2id) { var val1 = $('#'+value1id+'').val(); var val2 = $('#'+value2id+'').val(); if(val1 !== '' && val2 !== '') { if(parseFloat(val1) > parseFloat(val2)) { $('#'+value2id+'').validationEngine('showPrompt', 'Value 1 should be smaller than Value 2', 'error', true); } } } Here is the fiddle The code works and displays the error prompt but the form submits. Is there any way to tell validation engine to not just display the error prompt but to validate the condition and don't let the form submit until the condition is satisfied?

Aucun commentaire:

Enregistrer un commentaire