View Full Version : OnClick Event Help
04-10-2003, 06:19 PM
I have the following form:
I want the first 3 questions to be required:
* Troop # (required)
* District (required)
* Neighborhood (required)
Currently, it brings up the alert as soon as you click into the text field.
Is there a way to have this checked when the user clicks on the submit button instead?
04-10-2003, 06:24 PM
04-10-2003, 06:37 PM
I tried that.
The only problem is that I am using:
to submit the form.
I need to be able to prevent the user from accidentally submitting
the form with the enter button also.
04-10-2003, 06:44 PM
There's other ways to disable the enter-key-submission.
function checkKey( e )
var kc = ( e ) ? e.which : event.keyCode;
return ( kc != 13 );
<form ... onkeypress="return checkKey()" ... >
Or, include a confirmation in your validation script at the end
return confirm( "Are you ready to submit?" );Always use JS as a backup, and let HTML do the important work.
04-10-2003, 06:54 PM
Your checkKey function worked perfectly!
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.