How to get alert using Json object

Manideepgoud
Posted by Manideepgoud under jQuery category on | Points: 40 | Views : 2790
Hello DotnetFunda,
In this tutorial, am going to show how to get alert using Json object
Now lets get in to the code
Html part

<body>
<p>Login and Register form</p>
<form id="getingValues" style="width:30%;">
<fieldset>
Name:</br>
<input type="text" name="Name" id="Name"></br>
Age:</br>
<input type="text" name="Age" id="Age"></br>
Gender:</br>
<input type="text" name="Gender" id="Gender"></br>
Password:</br>
<input type="password" name="password" id="Password"></br></br>

<!-- Buttons -->
<input type="button" value="Login" id="loginbtn">
<input type="button" value="Register" id="Registerbtn">
</fieldset>
</body>


Coming to Javascript
<script>
var digitalData = "";
$(document).ready(function(){
$("#loginbtn,#Registerbtn").click(function(){
digitalData = {
"Login" :
{ "Name" : $('#Name').val(),
"Age" : $('#Age').val(),
"Gender" : $('#Gender').val(),
"Password" : $('#Password').val()
},
"Register" :
{ "Name" : $('#Name').val(),
"Age" : $('#Age').val(),
"Gender" : $('#Gender').val(),
"Password" : $('#Password').val()
}
};
alert($("#getingValues").serialize());
});
});
</script>

Hope, You will understand.

Comments or Responses

Login to post response