Hi, I have a form on an aspx page with several controls. I have one textbox which is invisible by default, but becomes visible (on postback) if the user chooses a particular value from a dropdownlist.
The textbox (tbAudience) can only contain a whole number. I have two validators pointing at tbAudience. One is a requiredfieldvalidator, the second is a regularexpressionvalidator.
When tbAudience is invisible the requiredfieldvalidator is automatically disabled. I thought I would have to handle this in code, but asp.net appears to automatically disabling the validator as it does not fire if the control is invisible.
My problem lies with the regularexpressionvalidator. The expression to be matched is very simple [0-9]{1,4}. If i type something into tbAudience which fails the test (a word for example) and then tab away from it (so it loses focus), the validator fires and fails.
This is the odd part. If I type the same word into tbAudience and then click on the my submit button, the regularexpressionvalidator does not fire. The page validates, even though tbAudience has a value which fails the expression.
I can't figure out why the regularexpressionvalidator fires when tbAudience loses focus, but not when the submit button is clicked. I have several other requiredfieldvalidators on the same form and they all seem to fire when the submit button is clicked.
Any guidance would be really appreciated. This is my second day trying to figure out this problem.
The textbox (tbAudience) can only contain a whole number. I have two validators pointing at tbAudience. One is a requiredfieldvalidator, the second is a regularexpressionvalidator.
When tbAudience is invisible the requiredfieldvalidator is automatically disabled. I thought I would have to handle this in code, but asp.net appears to automatically disabling the validator as it does not fire if the control is invisible.
My problem lies with the regularexpressionvalidator. The expression to be matched is very simple [0-9]{1,4}. If i type something into tbAudience which fails the test (a word for example) and then tab away from it (so it loses focus), the validator fires and fails.
This is the odd part. If I type the same word into tbAudience and then click on the my submit button, the regularexpressionvalidator does not fire. The page validates, even though tbAudience has a value which fails the expression.
I can't figure out why the regularexpressionvalidator fires when tbAudience loses focus, but not when the submit button is clicked. I have several other requiredfieldvalidators on the same form and they all seem to fire when the submit button is clicked.
Any guidance would be really appreciated. This is my second day trying to figure out this problem.