Click here to Skip to main content
16,021,041 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all ...

I want to know how to stop the button_click event if the email id in textbox is given invalid.
i am using regular expression validator but it is only showing that invalid emailid but button click is happening and that invalid email is storing in database.

Please send me the help...

Thanks
Nikhil
Posted

1 solution

Probably you must be checking the validation onClientClick of button control. This executes before server side event. But when you check the validation, you need to make sure the execution is stopped by setting return false properly.

something like:

HTML
onClientClick = if(InValid(someEmail)) return false;

JavaScript
function InValid(checkEmail)
{
 // use your logic here and return true or false accordingly. 
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900