Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
24
rated 0 times [  25] [ 1]  / answers: 1 / hits: 47785  / 11 Years ago, tue, july 23, 2013, 12:00:00

I am using ASP.NET and would like to do the following on client side because I do not want the page to reload (do not want postback). I would like to check for user input with following conditions:




  1. There are 2 radiobuttons and 2 textboxes and 1 button. Something like this:
    enter

  2. User must tick the radiobutton in order to activate the textbox (textboxes by default is disabled)

  3. If user tick radiobutton 1, textbox1 will be activated and textbox2 will be empty and disabled, if user press the button and textbox1 is empty message1 will activate.

  4. Same goes to the second radiobutton and textbox2.



Edit



I noticed that my button is in <asp:button> and not <input type=submit> therefore it will run my code behind to valdiate at server. Correct me if I am wrong. So how do I make my <asp:button> to validate user input without have to pass to server?


More From » asp.net

 Answers
1

You can try:



<asp:button onClientClick=return validateData();>


And in the JavaScript it should be:



function validateData() {
if (OK) {
return true;
} else {
return false;
}
}


return true will make your page be posted back to the server, and return false will prevent your page from doing that. Hope this helps.


[#76815] Sunday, July 21, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
yaquelina

Total Points: 517
Total Questions: 101
Total Answers: 96

Location: Egypt
Member since Tue, Jul 6, 2021
3 Years ago
yaquelina questions
;