I want to change required value in jquery validate from false to true and true to false.
if textbxox1 is empty i would like to set gobalvar=true else gobalvar=false,
but in jquery validate from not change value. it remember only true value.
How to solve ?
PHP code:
<form id="form1" name="form1" method="post">
<input type='text' id='textbox1' name='textbox1'/>
<input type='text' id='textbox2' name='textbox2'/>
<input type='submit' value='submit' id='save' name='save'/>
</form>
my js
var gobalvar=true;
if($('#textbox1').val()==""){
gobalvar=true;
}else{
gobalvar=false;
}
alert(gobalvar);
$("#from1").validate({
rules: {
textbox2:{required:gobalvar},
},
messages: {
textbox2:'required'
}
});