I keep getting the error The name can only contain underscores and alphanumeric characters. It must begin with a letter and be unique, and must not include spaces, end with an underscore, or contain two consecutive underscores. When I click on the Save Button in my page. The Button is supposed to save the values that are in the text box to the controller.

I believe it has to do with the line i create the save button. As the error page URL has setValuesInApex(%27j_id0:j_id5:startDate%27,%20%27j_id0:j_id5:endDate%27,%20%27j_id0:j_id5:reasonForSus%27) in it.

The Error log in the developer console does not have much information in it.

<apex:form >

            <apex:actionFunction action="{!save}" name="setValuesInApex" >

                <apex:param name="firstParam" assignTo="{!firstSusStr}" value="" />
                <apex:param name="secondParam" assignTo="{!lastSuspendDate}" value="" />
                <apex:param name="thirdParam" assignTo="{!reason}" value="" />

            <div class="col-lg-4" align="center">
                <h4>Select Student</h4>
                <input type="hidden" id="selStudent" style="width:300px" value="{!selectedName}"/>

            <div class="col-lg-4" align="center">  
                <h4>Starting Suspension Date</h4>

                <apex:inputText value="{!dateString}" id="startDate"/>


            <div class="col-lg-4" align="center">    
                <h4>Final Suspension Date</h4>

                <apex:inputText value="{!dateString}" id="endDate"/>


            <div class="col-lg-4" align="center">    
                <h4>Reason for Suspension</h4>

                <apex:inputText value="{!defReason}" id="reasonForSus"/>


            <div class="col-lg-4 col-lg-offset-4" align="center">  
                <apex:commandButton value="Save" id="do" action="setValuesInApex('{!$Component.startDate}', '{!$Component.endDate}', '{!$Component.reasonForSus}')" styleClass="btn btn-lg btn-success btn-block"/>


1 Answer 1


I thing you are trying pass the values into the actionFunction.

Currently it is passing the field.

Also, use onclick function of apex:commandbutton to call actionFunction instead of action

Use document.getElementById('{!$Component.startDate}').value for each values to be passed and it should be like this:

<apex:commandButton value="Save" id="do" 
                onclick="return setValuesInApex(document.getElementById('{!$Component.startDate}').value, document.getElementById('{!$Component.endDate}').value, document.getElementById('{!$Component.reasonForSus}').value);" 
                styleClass="btn btn-lg btn-success btn-block"/>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .