• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

javascript and asp.net validation question

fishjie

Senior member
So here's the scenario. I have a signup form that has a field "email address". I have a web.config switch "requireEmailSignup" that is either true or false. If the switch is true, I want to have client side and server side validation requiring the field to be there. If its false, then I don't want this validation. What's the best practice for doing something like this? Can I use the asp.net requiredfieldvalidator? I'm guessing I'll have to dynamically add the requiredfieldvalidator control in PageInit()?
 
The validator controls make it easy to add validation, and they work flexibly on the client and server based on the browser caps, so there's no real reason not to use them. The base validator sports a boolean property... may be called "Validate" or something along those lines... that enables/disables validation on the target control, and you can set that property in your code-behind based on the value in the config.
 
Back
Top