design pattern to use for complicated form

Go To StackoverFlow.com

2

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() );
2012-04-04 20:25
by Shinya Koizumi


2

Autocomplete is easy.

<input autocomplete />

If you want a decorator then use

function autoCompleteDecorator(input) {
    input.autocomplete = "on"
    return input
}
2012-04-04 20:28
by Raynos
I meant the jquery autocomplete like this one http://jqueryui.com/demos/autocomplete/remote.htm - Shinya Koizumi 2012-04-05 17:23
@ShinyaKoizumi implement it as a <select> problem solve - Raynos 2012-04-05 17:24
Yeah I did figure out that autocomplete part but how can I add validation to this control? It will be something like this? new CompanyNameValidate( new CompanyNameAutocomplete( new TextBox() ) ) - Shinya Koizumi 2012-04-05 20:40
Ads