Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
167
rated 0 times [  173] [ 6]  / answers: 1 / hits: 20112  / 12 Years ago, thu, july 26, 2012, 12:00:00

In my web application, in the login page, I have a checkbox. After entering the username/password, if the user doesn't tick the checkbox (T&C), he should not be taken to the home page, and an alert error message will be shown.



I have tried the following code. But it is not working. That is, an alert message is shown. But the user is taken to the next page(home page). I tried returning false, but no luck.



Can anyone tell how to fix this?



function doSubmit() {
var checkbox = document.getElementById(terms);
if (!checkbox.checked) {
alert(error message here!);
return;
}
document.getElementById(f).submit();
}​


I am calling doSubmit from



<input id=proceed onclick=doSubmit() type=submit value=${fn:escapeXml(submit_label)} />

More From » spring

 Answers
41

Try changing the input type to button instead of submit, delegating the submit action to JS function:



<input id=proceed onclick=doSubmit() type=button value=${fn:escapeXml(submit_label)} />

[#84041] Tuesday, July 24, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
noel

Total Points: 49
Total Questions: 90
Total Answers: 104

Location: Aland Islands
Member since Wed, Nov 17, 2021
3 Years ago
;