jQuery custom validation method issue -
i have select list that's default value (for please select) 0. due payment processing system , beyond control. have add.method states if select's value "0" return false, otherwise return true. works ok, except when change select's value else after submitting , getting error, error msg still displayed. how fix this
the html:
<form action="" method="post" id="singlepmnt"> <td> <select name="technology" class="select" id="singletech"> <option value="0" selected="selected"> please select</option> <option value="interactive brokers"> interactive brokers</option> <option value="mb trading"> mb trading</option> <option value="patsystems"> patsystems</option> <option value="pfg"> pfg (peregrine financial)</option> <option value="td ameritrade"> td ameritrade</option> <option value="trading technologies"> trading technologies</option> <option value="vision financial markets"> vision financial markets</option> <option value="hosted"> zen-fire</option> </select> </td> <td>single payment of $995</td> <td> <input type="hidden" name="item_number" value="34"> <input type="submit" value="" class="ordernow" /> </td> </form>
the validation rule using jquery.validate.js
$(document).ready(function() { $.validator.addmethod( "selecttechnology", function(value, element) { if ($("#singletech").val() === '0'){ return false; } else return true; }, "please select technology" ); var validator = $("#singlepmnt").validate({ rules: { technology: { selecttechnology: true } }, errorelement: "span", errorplacement: function(error, element) { error.appendto(element.parent("td")); } }); });
can't see error in this, appreciate help. thanks
try forcing validation in blur event.
$('#singletech').click(function() { $('#singlepmnt').validate().element('#singletech'); }); $('#singletech').blur(function(){ $('#singlepmnt').validate().element('#singletech'); });
jquery change() on <select> , firefox
the live link posted earlier seems work in ie, not firefox.
Comments
Post a Comment