function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
geetforcegeetforce 

fields does not contain required icon and getting wired error message

HI,

 

I have create one login page and set user name & password as required field.

 

This page is working fine but both fields are not showing reqired icon and when user submit this page with giving any value then User gets wired error message i.e. "j_id0:j_id2:j_id30:j_id33:j_id36: Validation Error: Value is required."

 


<apex:page controller="UserLoginVFC" showHeader="false" sidebar="false">
<br/>

<apex:form >
    <apex:pageMessages />
    
    <apex:pageBlock >
        <apex:pageBlockButtons >
            <apex:commandButton action="{!login}" value="Login" />
        </apex:pageBlockButtons>
        
        <apex:pageBlockSection >
            <apex:outputLabel >User Name</apex:outputLabel>
            <apex:inputText value="{!userName}" required="true"/>
        </apex:pageBlockSection>
        
        
        <apex:pageBlockSection >
            <apex:outputLabel >Password</apex:outputLabel>
            <apex:inputSecret value="{!password}" required="true"/>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>

</apex:page>

 

Thanks! 

NiketNiket

Hi ,

 

Use this code to get the required functionality :

 

<apex:outputPanel styleClass="requiredInput" layout="block">
<apex:outputPanel styleClass="requiredBlock" layout="block"/>
<apex:inputText value="{!userName}" required="true"/>
</apex:outputPanel>
</apex:outputPanel>

 

Also , do the same for password field as well.

 

Please mark it as the solution if it answers your question and if you have any question, let me know.

 

Ckeck My Blog

 

 

geetforcegeetforce

Hi Niket,

 

Thanks for your reply.

 

Here I have couple of questions:

1. Is it a bug in SFDC that it is not able to load/add "required" css/panel with fields or I did something wrong here.

2. What about validation error message, how can i fix this. currently I am getting "j_id0:j_id2:j_id30:j_id33:j_id36: Validation Error: Value is required." message string.

 

regards

 

NiketNiket

Hi ,

 

I don't think it is a bug. Have you tried the code mentioned in my previos comment  for userid and password both?

 

I believe it should work in the way I mentioned.