You need to sign in to do that
Don't have an account?
naveen kunuru
custome validation
custom validation to check field is not empty while saving, if field is empty display error message
here is my code is this code is ok?please let me known any allternation code from u guys
<apex:page controller="task43" sidebar="true" showHeader="true">
<apex:form >
<apex:pageBlock title="homepage" id="block1">
<apex:pageBlockSection >
<apex:pagemessages >
</apex:pagemessages>
<apex:inputText value="{!f1}"/>
<apex:inputText value="{!f2}"/>
<apex:commandButton value="login" action="{!log}" reRender="block1"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
public with sharing class task43 {
public PageReference log() {
if(f1==''||f1==null&&f2==''||f2==null){
apexpages.addmessage(new apexpages.message(apexpages.severity.warning,'please enter'));
}
return null;
}
public String f2 { get; set; }
public String f1 { get; set; }
}
here is my code is this code is ok?please let me known any allternation code from u guys
<apex:page controller="task43" sidebar="true" showHeader="true">
<apex:form >
<apex:pageBlock title="homepage" id="block1">
<apex:pageBlockSection >
<apex:pagemessages >
</apex:pagemessages>
<apex:inputText value="{!f1}"/>
<apex:inputText value="{!f2}"/>
<apex:commandButton value="login" action="{!log}" reRender="block1"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
public with sharing class task43 {
public PageReference log() {
if(f1==''||f1==null&&f2==''||f2==null){
apexpages.addmessage(new apexpages.message(apexpages.severity.warning,'please enter'));
}
return null;
}
public String f2 { get; set; }
public String f1 { get; set; }
}
Try this condition
if(f1.trim().length()==0 || f2.trim().length()==0)
It will first remove the blank spaces and then check the length of string..
All Answers
Try this condition
if(f1.trim().length()==0 || f2.trim().length()==0)
It will first remove the blank spaces and then check the length of string..
apexpages.addmessage(new apexpages.message(apexpages.severity.warning,'please enter'));