jquery - Ignore validations on few fields according to another field -


i use jquery validation engine validate following form.

static <input type="radio" name="mode" value="static" data-validation-engine="validate[required] radio" data-prompt-position="topright:-70"/>  dhcp <input type="radio" name="mode" value="dhcp" data-validation-engine="validate[required] radio" data-prompt-position="topright:-70"/>  ip <input type="text" name="ip" id="ip" data-validation-engine="validate[required,custom[ipv4]]" data-prompt-position="topright:-70"/>  gateway <input type="text" name="gateway" id="gateway" data-validation-engine="validate[required,custom[ipv4]]" data-prompt-position="topright:-70"/>  dns <input type="text" name="dns" id="dns" data-validation-engine="validate[required,custom[ipv4]]" data-prompt-position="topright:-70"/> 

normally ip/gateway/dns validate per rules, need ignore ip/gateway/dns validation when dhcp mode selection. (validations needs static mode selection)

in jquery script initialize validateengine below.

$("#my_form").validationengine(); 

any idea how can archive task.

called function onchange event of radio button, if dpcp, state true otherwise false

function state_change(state){     if(state){         $('#ip').removeattr("data-validation-engine");         $('#gateway').removeattr("data-validation-engine");         $('#dns').removeattr("data-validation-engine");     } else{         $('#ip').attr("data-validation-engine","validate[required,custom[ipv4]]");         $('#gateway').attr("data-validation-engine","validate[required,custom[ipv4]]");         $('#dns').attr("data-validation-engine","validate[required,custom[ipv4]]");     } } 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -