You need to sign in to do that
Don't have an account?
Richtext InputTextArea: Prevent from submitting on enter
I've built a simple Visualforce page used to compose emails, using an inputTextArea with richText = true for the body of the email. The problem is, anytime you hit enter while in that inputTextArea, instead of adding a line break it submits the form (i.e. sends the email). I've tried setting the form to immediate = false, and adding an actionSupport for the onenter event with no action, but it still happens. Anyone know how to get around this? The page is below.
<apex:page standardController="Contact" extensions="extEmailPO2"> <apex:form id="editorForm"> <apex:pageBlock id="pageEmail"> <apex:pageBlockButtons > <apex:commandButton action="{!send}" value="Send" id="theButton" immediate="false"/> </apex:pageBlockButtons> <apex:pageBlockSection columns="1"> <apex:pageBlockSectionItem > To: <apex:outputText value="{!POEmail}"/> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > Subject: <apex:inputText id="subject" value="{!eSubject}" required="true" style="width: 400px"/> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:inputTextarea id="email" richtext="true" value="{!eContent}" required="true" > <apex:actionSupport event="onenter"/> </apex:inputTextarea> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
tried your code, and bound the input text area to contact.description and it worked, pressing enter advances to the next line in the rich text area, does not submit the form.
what are you binding this field to in your controller ? a string ?
if you change it to this :
<apex:inputTextarea id="email" richtext="true" value="{!contact.description}" required="true" > </apex:inputTextarea>
All Answers
tried your code, and bound the input text area to contact.description and it worked, pressing enter advances to the next line in the rich text area, does not submit the form.
what are you binding this field to in your controller ? a string ?
if you change it to this :
<apex:inputTextarea id="email" richtext="true" value="{!contact.description}" required="true" > </apex:inputTextarea>
Yeah, it works for me when I bind it to the description field as well. I'm trying to bind it to a string variable (eContent) in my extension. I actually had to switch tactics since I first started building this and don't really need Contact as the standardController anymore, so I tried changing it so my extension is the controller and it works fine that way, so I'll just keep it like that. Odd though.
Thanks!