Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Create a text box validation variable
Message
 
 
General information
Forum:
ASP.NET
Category:
Web forms
Miscellaneous
Thread ID:
01653138
Message ID:
01653164
Views:
38
>>>>Hi,
>>>>
>>>>Say I have text box (asp:textbox) on a page which has a RequiredFieldValidator so that the text box cannot be left blank.
>>>>
>>>>And then I have a validation method that checks if the user entry is valid; that is, if DB has this entry in the table. If user enters wrong value, the page says "Invalid Entry - blablabla".
>>>>
>>>>But the user can still click on Submit button. And since the RequiredFieldValidator will not stop it (some "bad" entry is in the text box), the Submit click method will fire. I want to prevent it.
>>>>
>>>>So, when the code validation method check for a valid entry (in code behind) and find that the entry is not valid, I want to set a flag that will prevent Submit to fire.
>>>>
>>>>How do you do it?
>>>
>>>One approach here : https://stackoverflow.com/questions/5929186/how-to-prevent-form-submission-while-using-html5-client-side-form-validation-in
>>>
>>>I use angular. Easy to disable the button when a form is invalid - better than allowing a click and then rejecting it.....
>>
>>I agree - have not thought about this - that disabling the button until all controls are validated is a nice approach. I am not going to learn angular but I will see if this is possible with plain vanilla ASP.NET web forms.
>>Thank you.
>
>Lots of solutions on the web - especially with jQuery. But angular should be looked at (even if for just simple data binding). All it takes is something as simple as this: http://www.angularjshub.com/examples/basics/controller/
>(Example using 1.x version though - Angular 2 uses a different paradigm)

Thank you. But you would recommend learning Angular with version 2 instead of going back to 1, right?
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform