Checking change in form field before executing AJAX
i have a form on my view page.. whenever form populate on the page ..it is
filled with old values ... i mean input box and check-box have old values
... and then i am posting form through ajax..after posting if values
successfully saved into database i am showing the message that information
updated successfully or vice versa...so the problem is now that if for
example user do not change anything,the form values are same in the
text-boxes then when user pressed save button i don't want to show him
that information has updated as he didn't do anything .. i want to ask if
that possible in java script ...or should i have to query into the
database and check that whether values are same or not? and the other
thing that if it can be possible that button remains disable until he do
some changes in any of the form field...
i am not writing the whole code just the java script part
$("#submit").click(function(e){
e.preventDefault();
var name = $('#name').val();
var email = $('#email').val();
var password = $('#password-check').val();
var oldpassword = $('#oldpassword').val();
var timezone = $('#UserinfoTimezone').val();
var alternate_email = $('#alternate_email').val();
//var newsletter = $('#newsletter').val();
var form_data = {
name: $('#name').val(),
email: $('#email').val(),
password: $('#password-check').val(),
oldpassword: $('#oldpassword').val(),
timezone: $('#UserinfoTimezone').val(),
alternate_email: $('#alternate_email').val(),
};
$.ajax({
type:"POST",
data:form_data,
url:"https:/localhost/settings/",
success : function(data) {
alert("successfully data saved"):
No comments:
Post a Comment