Currently working on local storage where In the first page I have two radio buttons if user select first radio button in the second page panel has to hide. And if user select radio button one text field from second page validation should not happen. I have no idea how to use localStorage or ajax which one will be the best.
When I saw SO I got something window.localStorage.setItem("key_name", "stringValue");
How can I use this?
First page code
<!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="first_radio"/>
<input type="radio" name="radio" id="second_radio"/>
<input type="button" value="submit" id="btn_sub"/>
</form
</body>
</html>
Second page
<!DOCTYPE html>
<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="field" />
<input type="button" required value="Submit" id="btn_sub1" />
</form>
</body>
</html>
Currently working with jQuery as per the below user helped me.
in the first page I am setting like this
storeData();
function storeData()
{
alert("check");
localStorage.setItem('pg', $('#basicForm #pg').attr('checked', 'checked'));
//alert("yes" + getd);
localStorage.setItem('cu', $('#basicForm #cu').attr('checked', 'checked'));
}
When I am setting this in the second page by default the particular div was hiding if the user open second page directly.
if( localStorage.getItem('pg') )
{
$('#edu_info').hide();
}