all groups > dotnet jscript > november 2005 >
You're in the

dotnet jscript

group:

Multiple events with one event handler


Multiple events with one event handler Cleako
11/21/2005 1:41:02 PM
dotnet jscript:
I am trying to run the following code:

onsubmit="return
ValidateForm(document.AddRepayment.txtDate1,'lblDate1Req');return
ValidateForm(document.AddRepayment.txtDate2,'lblDate2Req');return
ValidateForm(document.AddRepayment.txtDate3,'lblDate3Req');"

I have tried a few ways, one was to include it in the code behind of my
ASP.NET page and use the button.attributes.add method and I also tried it
with the onclick event in the HTML portion of the page and it kept giving me
errors so now I am trying the onsubmit event which allows the code to run but
still does the 1st validation and bypasses the rest. All the ways that allow
it to run will only use the 1st ValidateForm call no matter what happens.

Once the first one is valid then it goes to the code behind like I didnt
include 2 others. Please let me know what I may be doing wrong.

Thanks,
Re: Multiple events with one event handler Martin Honnen
11/22/2005 12:00:00 AM


[quoted text, click to view]

You should return true from the onsubmit handler if you want to submit
the form and false otherwise so you want to use
onsubmit="
return ValidateForm(document.AddRepayment.txtDate1,'lblDate1Req') &&
ValidateForm(document.AddRepayment.txtDate2,'lblDate2Req') &&
ValidateForm(document.AddRepayment.txtDate3,'lblDate3Req');"


--

Martin Honnen --- MVP XML
AddThis Social Bookmark Button