http://jsbin.com/viraqixicigi/1/edit?html,css,js,output
Here, I am saving input in cookies. When I re-open it will show all the data I enter. My question is when I enter wrong data, the input turns red, but when I close and reopen the file the wrong input is not red. Can any one help? Thank you.
//save as cookies var formsave1=new autosaveform({ formid: 'save', pause: 1000 //<--no comma following last option! })
To get your code working - try moving your validation code after your autosaveform function call e.g.
//save as cookies
var formsave1=new autosaveform({
formid: 'save',
pause: 1000 //<--no comma following last option!
});
//this code is after...
if(document.getElementById(id).value.toUpperCase()==(id)){
document.getElementById(id).style.backgroundColor = "green";
} else {
document.getElementById(id).style.backgroundColor = "red";
}
I am curious however, how your form validation is being called when you change input - seems like you want to move that into a function and call it from the cc function when the input changes or when the form is submitted.