Jump to content
  • 0

How To Disable The Enter Key From A Text Area?


daniellopez

Question

Need help in disabling the Enter Key from a  text area in a Submission Form and an Update Form.  Since I later on use that parameter to pass it on to another form and if the user used the Enter key, this passing of parameters results in an error.  

 

This is what I have on the header of the submission form but still is not working:

 

<script language="javascript" type="text/javascript">
function stopRKey(evt) {
var evt  = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type=="text")) { return false; }
}
document.onkeypress = stopRKey;
</script>
 
The field I want to prevent is named as: "[@Status_trial]"
 
I will greatly appreciate the Help!
Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

As I understand you would like to disable a field if that is the case then use the following script in the footer of the page:

<script>
function f_disable(){
document.getElementById('InsertRecordStatus_trial').disabled= 'true';
} 
f_disable();
</script>

change InsertRecordStatus_trial to EditRecordStatus_trial for update form

Link to comment
Share on other sites

  • 0
Hello!

If I understand correctly, you don't need to disable the Enter Key, you need to remove paragraphs from the parameter.

In this case you can use code like

 

<script language="JavaScript">

function textReplace()

{

var text = document.getElementById("ID").value;

text = text.replace(/\n/g, " ");

alert(text);

document.getElementById("ID").value = text;

}

document.getElementById("caspioform").onsubmit=textReplace;

</script>

 

Your "ID" for Submission Form will be, probably, "InsertRecordStatus_trial" and for Update Form "EditRecordStatus_trial"

 

When a user clicks the Submit button, paragraphs are removed from the entered text and the parameter is passed without paragraphs.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...