Subject: onclick="javascript: return false" on vista
Posted By: gabrieldcr2 Post Date: 4/25/2008 11:18:31 AM
Hi Folks:

I have tried the following validation code before a submit takes place:

<asp:Button .... onclick="JavaScript: return validation();"

it used to work fine, but when I tried to test my page on ie in windows vista, it simply executes the submit whithout evaluating the return of the function (true or false).

My question is: do i have to do another type of validation?

Regards,
Gabriel

Reply By: philip_cole Reply Date: 5/25/2008 6:09:34 PM
Hi Gabriel,

Are you sure your syntax is correct? For an <asp:Button> you need to use the OnClientClick attribute as OnClick is the back end event handler. Also, you shouldn't add the Javascript: prefix (for onlick or OnClientClick).

If that is set up correctly and it still submits, there may be a javascript error occuring in your validation function. When an error is thrown, the whole onclick event stops immediately, i.e. the return false doesn't get reached, and so the form submits as normal.
Of course, there may also be a logical error somewhere within validation which is returning true when it shouldn't be.

HTH

Phil
Reply By: mfreidge Reply Date: 6/4/2008 9:40:39 AM
see http://forums.asp.net/t/1161858.aspx?PageIndex=1

OnClientClick="if(confirm('Selected records will be deleted?')==false){event.returnValue=false;return false;}else{return true;}"


Go to topic 71820

Return to index page 1