Is form is durty

function GetFormData() {

oForm.Add(‘span’, $(‘span:not(:disabled)’).toEnumerable().ToObject(“i=>i.attr(‘name’)”, “i=>(i.is(‘:disabled’)?”:i.text())”));

oForm.Add(‘input’, $(“input:not(:disabled)”).toEnumerable().ToObject(“i=>i.attr(‘name’)”, “i=>i.val()”));

}

function isModifiedForm(au) {

var oChangeForm = $.Enumerable.Empty().ToDictionary();

oChangeForm.Add(‘span’, $(‘span:not(:disabled)’).toEnumerable().ToObject(“i=>i.attr(‘name’)”, “i=>(i.is(‘:disabled’)?”:i.text())”));

oChangeForm.Add(‘input’, $(“input:not(:disabled)”).toEnumerable().Where(“i=>i.attr(‘name’)!=’tags'”).ToObject(“i=>i.attr(‘name’)”, “i=>i.val()”));

var tempEnumB=Enumerable.From(oChangeForm.Get(“input”));

var tempEnumA=Enumerable.From(oChangeForm.Get(“input”));

var NoofInputChanged = false;

var NoofSpanChanged = false;

 

var hasInputChanges = tempEnumB.Count() != tempEnumA.Count();

if (hasInputChanges) {

NoofInputChanged = tempEnumB.Join(tempEnumA, “i=>i.Key”, “o=>o.Key”, “i,o=>{K:i.Key, IsEq:(i.value==o.value)}”).Where(“x=>x.IsEq==false”).Count();

}

 

tempEnumB=Enumerable.From(oChangeForm.Get(“span”));

tempEnumA=Enumerable.From(oChangeForm.Get(“span”));

 

var hasSpanChanges = tempEnumB.Count() != tempEnumA.Count();

if (hasSpanChanges) {

NoofSpanChanged = tempEnumB.Join(tempEnumA, “i=>i.Key”, “o=>o.Key”, “i,o=>{K:i.Key, IsEq:(i.value==o.value)}”).Where(“x=>x.IsEq==false”).Count();

}

if (au) { alert(“Nothing to save!”) }

getServerElementById(‘hfDirtyForm’).value = hasInputChanges || NoofInputChanged || hasSpanChanges || NoofSpanChanged;

return hasInputChanges || NoofInputChanged || hasSpanChanges || NoofSpanChanged;

}

Leave a Reply