My form has a number of fields with autocomplete and trying to refactor so I am not creating spaghetti code in javascript. And for those autocomplete fields I need to validate with remote call on submit. For autocomplete I would use the decorator pattern but I am not sure how can I implement the validation part.
textBox = new ZipCodeAutocomplete( new TextBox() );
textBox2 = new CompanyNameAutocomplete( new TextBox() );
Autocomplete is easy.
<input autocomplete />
If you want a decorator then use
function autoCompleteDecorator(input) {
input.autocomplete = "on"
return input
}