Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable the Enter Key when on a CGI script 2

Status
Not open for further replies.

jlucyk

IS-IT--Management
Aug 1, 2001
10
US
Is there any way in Java that you can disable the enter key when filling out a form thru a cgi script. When the person fills out the form on the web and hits the enter key it messes up the output to the text file. Please let me know.

John
 
1- this is NOT a java forum
there IS a java forum

2- what do you mean with : filling out a form thru a cgi script ?
- the cgi script fills out the form and then sends it to the client : where does the keypress event can happen ??
- the users fills a form and when s/he presses enter, the form submits itself : where is the cgi ? you mean, you want the form NOT to submit if the user presses the enter key ?
 
When someone hit the enter key in the comments space on a form with the cgi script in the background it messes up the log file and when I try to import into access it imports into multiple records instead of one. I saw a java progammer use a routine that disabled the right mouse click so you can't get to the code in back of the page. I was wondering if there was any way to disable the enter key so no one can enter on the form. Like have message pop please do not use the enter key.

Please help

John
 
I think your only problem is that you need to set a parameter (WRAP) in the textarea tag so that hard returns entered into the textarea are NOT transmitted to the cgi program. Check this out (from NS devedge):

WRAP

specifies whether lines longer than the text area's column width wrap to the next line. Navigator 2.0.
The value of WRAP can be one of the following:


OFF disables word wrap. Text the user types is displayed with the exact line breaks that the user types. If the user explicitly inserts a line break, however, the break is included as part of the text area's value. The user has to scroll horizontally to see the ends of lines that do not fit in the text area element.

HARD causes word wrap, and the line breaks are included when the form is submitted. The text wraps inside the text area element, and that the user does not need to scroll horizontally.

SOFT causes word wrap, but the line breaks are not included when the form is submitted.

Looks like you need to use WRAP=SOFT.
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
I tried the wrap=soft in the html code and it still is not working!!! I tried hit enter a view time in the box and it gives me carriage returns in the log file.
 
If you want to prevent users from using carriage returns in textarea fields, have javascript search the contents of the textarea for "%0D%0A" (carriage return,line feed) before submitting the form.

Example:

if (escape(field_value_ref).indexOf("%0D%0A") >= 0) {

// action to prevent submittal

}

TW
 
or, don't use ie ;]]]
under netscape enter doesn't auto submit the form ;]

or, catch the enter key pressed event and make it fire NOTHING

TW, is it the same code for all platforms ? i'm wondersing for instance under linux or mac if the \n\r isn't encoded differently ...
 
Try this:

[tt]<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--
var submitForm = false;

function submitBtn(vCheck){
if(vCheck){
submitForm = true;
return submitForm;
}else{
alert(&quot;You must use the Submit button&quot;);
return false;
}

}
//-->
</SCRIPT>[/tt]

[COLOR=000080][tt][COLOR=FA5000]<FORM ACTION=&quot;test.cfm&quot; METHOD=&quot;post&quot;
ONSUBMIT=&quot;return submitBtn(submitForm);&quot;>[/color][/tt][/color]

[COLOR=000080][tt][COLOR=FA5000]<INPUT TYPE=&quot;Text&quot; NAME=&quot;myText&quot;>[/color][/tt][/color]
[COLOR=000080][tt][COLOR=FA5000]<INPUT TYPE=&quot;Submit&quot; NAME=&quot;Submit&quot;
ONCLICK=&quot;return submitBtn(true)&quot;>[/color][/tt][/color]

[COLOR=000080][tt][COLOR=FA5000]</FORM>[/color][/tt][/color] - tleish
 
Iza, I have no idea if the solution we're using work's outside of windows or mac. Our application is not public and we don't have any of those users. I am hoping the escape function takes care of that ??

TW
 
Thank you for all your help!! I put tleishs' idea on my website I changed the comments field from areatext box to just a regular text box now it works awesomely.

Thank you again.

John
 
tw, if it works for you and every user will use the same config as you do, it's fine !
anyway tlesh function rules !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top