JSFiddle - React, Tailwind, and code Playground
HTML
<form id="My50PageForm">
<input name="forename" value="barny"> try editing this field<br>
<input name="surname" value="something"><br>
<button id="save">Check for changed values</button>
</form>
JavaScript
$(document).ready(function(){
//Copy all form valued into a data attribute called 'original' when the page loads
$("#My50PageForm :input").each(function(elem){
$(this).data("original",$(this).val());
});
//here's where
$("#My50PageForm").submit(function(){
var elems = $("#My50PageForm :input").filter(function(value){
var elem=$(this),
original=elem.data("original");
console.log(original);
//check that original isn't 'undefined' (like the button) and that it's been changed
return original && elem.val()!==original
});
if(elems.length){
$.post("http://jsfiddle.net/example.cfm",
elems.serialize());
}else{
alert("nothing changed");
}
return false;
});
});