You need to sign in to do that
Don't have an account?
Ricker
Cancel button on VF page
I have cancel button on VF page which displays bunch of required fields when users click cancel instead of saving the record is saved without filling of required fields I want to throw some error when user clicks cancel stating there is a required field that needs to be filled, is there any way I can accomplish this
Try below code:
<apex:pageBlock id="myblock">
Email <apex:inputText value="{!email}" id="email"/><br/><br/>
<div class="errorMsg">
<strong></strong> {!emailError}
</div>
<apex:commandButton value="Click me!" action="{!checkEmail}"/>
</apex:pageBlock>
Apex:
public void checkEmail() {
if(!Pattern.matches('[a-zA-Z0-9._-]+@[a-zA-Z]+.[a-zA-Z]{2,4}', email))
{
emailError ='Either first name or middle name must be defined';
}
}
Regards,
Suraj