Shinya Koizumi
Shinya Koizumi

Reputation: 1103

design pattern to use for complicated form

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() );

Upvotes: 2

Views: 207

Answers (1)

Raynos
Raynos

Reputation: 169451

Autocomplete is easy.

<input autocomplete />

If you want a decorator then use

function autoCompleteDecorator(input) {
    input.autocomplete = "on"
    return input
}

Upvotes: 2

Related Questions