Skip to main content
September 12, 2013
Question

more than 1 function in cfform tag "onSubmit"

  • September 12, 2013
  • 1 reply
  • 1541 views

i need to call atleast 3 javascript functions in a form

using "onSubmit" works fine with one function but when i try to add another nothing happens....

<cfform

action="postpage.cfm" method="POST"

target="_self"

onsubmit="if(document.getElementById('Agree').checked) { return true; } else { alert('You must agree to the Terms and Conditions'); return false; }">

"return checkEmail(this);" is one of the funtions. it checks to see if 2 cfinputs are the same

how do i add multiple functions to onSubmit

tnx in advance

This topic has been closed for replies.

1 reply

BKBK
Community Expert
Community Expert
November 20, 2013

ColdFusion is simply behaving as it should. You will notice that the script that currently runs upon onSubmit ends in a return-statement. That signals the end of the event-handler. 

If you wish to check the e-mail as well, you could run one script that performs both functions. I was thinking of something like the following, just off the cuff

onsubmit="if(!document.getElementById('Agree').checked) {alert('You must agree to the Terms and Conditions'); return false; } else {return checkEmail(this);}">