This question is continue with my previous question localstorage In the first page if the user select second radio button and click submit button in the second page I have four text field where I have to validate only two text field using jquery validate.
Here is the first page
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-1.11.3.js"></script>
<meta charset="utf-8">
<title>First page</title>
</head>
<body>
<form id="first_pge" class="first_pge" action="second.page">
<input type="radio" name="radio" id="ug"/>
<input type="radio" name="radio" id="pg"/>
<input type="radio" name="radio" id="cu"/>
<input type="button" value="submit" id="btn_sub"/>
</form
</body>
</html>
Here is the second page code
<html>
<head>
<script src="https://code.jquery.com/jquery-1.11.3.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.14.0/jquery.validate.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.14.0/additional-methods.min.js"></script>
<script>
jQuery.validator.setDefaults({
debug: true,
success: "valid"
});
$("#myform").validate({
rules: {
field: {
required: true
}
}
});
</script>
<meta charset="utf-8">
<title>JS Bin</title>
<style>
.div_panel {
background-color: yellow;
font-size: 16px;
}
</style>
</head>
<body>
<form id="myform" class="myform">
<div class="div_panel">First</div>
<div> </div>
<input type="text" id="field" class="local_Field" name="local_Field" />
<input type="text" id="field_1" class="local_Field" name="local_Field" />
<input type="text" id="field" class="local_Field" name="local_Field" />
<input type="text" id="field_1" class="local_Field" name="local_Field" />
<input type="button" required value="Submit" id="btn_sub1" />
</form>
</body>
</html>
First page jquery localstorge code
function assignValue() {
var checkedRadioValue = -1;
if (document.getElementById("ug").checked)
{
checkedRadioValue = 1;
}
else if(document.getElementById("pg").checked)
{
checkedRadioValue = 2;
}
else if(document.getElementById("cu").checked)
{
checkedRadioValue = 3;
}
//localStorage.setItem("CheckedRadioValue", checkedRadioValue);
localStorage.setItem("CheckedRadioValue", checkedRadioValue);
}
assignValue();
this is what i have in the second page jquery code
$(document).ready(function(){
//var checkedRadioValue = parseInt(localStorage.getItem("CheckedRadioValue"));
var checkedRadioValue = parseInt(localStorage.getItem("CheckedRadioValue"));
if (checkedRadioValue != -1) {
if (checkedRadioValue === 3) {
//$("#edu_info").hide();
//$('.local_Field,.txt_ara').removeClass('required_Field');
$(".myform").validate({
ignore: ".local_Field"
});
}
/* if (checkedRadioValue === 2) {
}*/
sessionStorage.removeItem("CheckedRadioValue");
}
});
I have tried using ignore in jquery validator but still no use kindly please help me.
Kindly please help me
Thanks in advance