I am trying to validate the data of the input text if the existing value is changed then validate and throw error. Though I am able to capture the default value and validate with the new changed value. However, if the user goes back and change to the old value again how would I handle or capture that? Seems like default value will change once the value is changed, how can I preserve the original value of that input text regardless of any multiple changes happens on the input value?
//Note: This function will only triggers with on submit of the form
function A() {
var firstName = document.getElementById('firstName');
var holdFirstName = firstName.defaultValue;
if (firstName.value === firstName.defaultValue) {
return false;
}
}