View Full Version : 2 function with submit event handler
Yammaski
02-18-2011, 10:58 AM
I want 2 functions checked onsubmit event handler.
First function checkchars(cur) has to be true : max 5 chars for textwidth 5 cm, max 10 chars for textwidth 10 cm, .... .
Second function radio_button_checker() has to be true : check if a radio button is hit.
I tried a lot of things in vain.:(
Prototype (http://www.frogstyling.be/X_Tests/maxChars_RBut_Check.asp)
Yam.
djr33
02-18-2011, 04:09 PM
onSubmit="if (!checkchars(this)||!radio_button_checker()) { return false; }"
As I said in the other thread, always remember the final semi-colons. It may not seem important now, but it will really help to debug things later.
Also, this assumes that your functions are working now.
Alternatively you could place that in a new function like this:
function checkform(form) {
if (checkchars(form)&&radio_button_checker()) { return true; }
return false;
}
Use it like this:
onSubmit="return checkchars(this);"
Yammaski
02-18-2011, 05:04 PM
onSubmit="if (!checkchars(this)||!radio_button_checker()) { return false; }"
The alert works, but when the number of chars is ok ... nothing happens.
The new function : alert for chars works, but no alert when no radio button is checked.
djr33
02-18-2011, 06:44 PM
That is because of the way that it processes the AND/OR commands.
It fails before continuing.
Try this:
function checkform(form) {
var check1 = checkchars(form);
var check2 = radio_button_checker();
if (check1==true&&check2==true) { return true; }
return false;
}
Yammaski
02-18-2011, 07:05 PM
Almost ... but the submit doesn't send anything. When the text is send, it appears under the textfield.
onSubmit="return checkform(this);"
Test (http://www.frogstyling.be/X_Tests/maxCharsCheck_DD.asp)
djr33
02-18-2011, 07:37 PM
Try this:
onSubmit="if (!checkform(this)) { return false; };"
Yammaski
02-18-2011, 07:41 PM
same result :(
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.