goodmorningsky Posted April 18, 2005 Posted April 18, 2005 Hi, all. I got stuck...here.. Let me simplify my problem.. I added One TextBox, and Required Validator associated with the textbox. And, Submit button. When submit is clicked it should do some thing before submit. So, when button clicked javascript function "SaveData()" must be called. So, I added following code to Page_Load event. this.btSubmit.Attributes.Add("onclick","return SaveData() ;") ; After adding this, validator doesn't work! Event with empty textbox, it still submit to server without stopping.. SaveData() is this. <script language="javascript"> <!-- function SaveData() { if (!true) return false ; try{ //do nothing }catch(e){} return true ; } --> </script> and the client side code generated is following. <input type="submit" name="Button1" value="Button" onclick="return SaveData() ;if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); " language="javascript" id="Button1" /> It seems validator doesn't work if there is javascript function call. How can I do both, calling javascript code and using validator? Any comment will help! Thank you. Quote Sun Certified Web component Developer, Microsoft Certified Solution Developer .NET, Software Engineer
kahlua001 Posted April 18, 2005 Posted April 18, 2005 Try without the 'return' in your js call, ex.. onClick="SaveData()" Quote
goodmorningsky Posted April 19, 2005 Author Posted April 19, 2005 Thank you I got it. I solve with following.. this.btSumit.Attributes.Add("onclick","if(!SaveData()){return false;}") ; Quote Sun Certified Web component Developer, Microsoft Certified Solution Developer .NET, Software Engineer
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.