Here's some simpler JavaScript, that doesn't require an ExtraHTMLText setting:
===================================
//this function prevents the ENTER key from submitting the form
function enterKey(event) {
if (event.which == 13)
{
return(false);
}
}
document.captureEvents(Event.KEYPRESS);
document.onkeypress=enterKey;
===================================
janet
(Embedded
image moved Adam Killander <[EMAIL PROTECTED]>
to file: 09/30/99 04:53 AM
pic30136.pcx)
To: [EMAIL PROTECTED]
cc: (bcc: Janet Traub/IS/SSC/THD)
Subject: Re: [ND] Preventing ENTER button to submit a form
You could use some JavaScript to disable the enter buttons default
action (to submit the form) if there are only one textfield on the page
even though I don't understand why you want to do this.
on your ND-page:
ExtraHTMLText="onsubmit=return checkNumOfTextBoxes(this)"
in the htm-file:
add the JavaScript function in the HEAD tag
ex.
function checkNumOfTextBoxes(myForm) {
var numOfTextBox = 0
for (var i=0; i<myForm.elements.length; i++) {
numOfTextBoxes += (my_forms.elements[i].type == "text") ? 1 : 0
}
return (numOfTextBoxes != 1)
}
/Adam Killander
Ferdinand Say wrote:
>
> how do i prevent the enter button to submit the form when there is only 1 text
box in the page?
>
> if there are 2 textboxes, pressing enter does nothing. i want this behavior
if there is only 1 text box.
>
> thanks.
>
> ferdie
_________________________________________________________________________
For help in using, subscribing, and unsubscribing to the discussion
forums, please go to: http://www.netdynamics.com/support/visitdevfor.html
For dire need help, email: [EMAIL PROTECTED]
pic30136.pcx