Question
input text field validation - design advice request
Newbie here, so please be gentle.
I want to have some automatic validation of 2 input fields. One will allow integers only and another will allow decimals. I will also want to check that the numbers entered fall within a particular range. So a couple questions. First, I am trying to use OO techniques by developing classes. Should I write 2 new Classes called IntegerTextField and DecimalTextField that each subclass TextField? (If so, how should I intercept the key strokes inside these new classes so that I can check what has been entered.) Or is it better to create a new class that just holds static functions for checking fields and then call those functions as needed?
Second, does anyone have advice and/or a code snippet that demonstrates the best way to strip out non-numeric characters?
Thanks in advance for any help you gurus can provide.
I want to have some automatic validation of 2 input fields. One will allow integers only and another will allow decimals. I will also want to check that the numbers entered fall within a particular range. So a couple questions. First, I am trying to use OO techniques by developing classes. Should I write 2 new Classes called IntegerTextField and DecimalTextField that each subclass TextField? (If so, how should I intercept the key strokes inside these new classes so that I can check what has been entered.) Or is it better to create a new class that just holds static functions for checking fields and then call those functions as needed?
Second, does anyone have advice and/or a code snippet that demonstrates the best way to strip out non-numeric characters?
Thanks in advance for any help you gurus can provide.