Hossein Nasr
Hossein Nasr

Reputation: 1458

Range validation in Wicket when using TextField<Integer>

I have TextField<Integer> and i want to validate that the input contain exactly 8 digit. if it was TextField<String> i would simply add a PatternValidator("(\\d){8}") to it but PatterValidator extends IValidator and I cant add it to TextField<Integer>

how can i validate this textField. i need to use TextField<Integer> because this component automatically convert all numbers in UTF8 to Integer

Upvotes: 2

Views: 1118

Answers (1)

Michał Krzemiński
Michał Krzemiński

Reputation: 1251

You can attach a RangeValidator and set range you are looking for. It shouldn't change html and will validate on form submit.

RangeValidator.range(10000000, 99999999);

Upvotes: 2

Related Questions