You need to sign in to do that
Don't have an account?
Enry
Field Email Validation
I have a simple VF form and i would like to validate the email address field when the user click on Submit.
<apex:page id="loginPage" showHeader="false" controller="SiteRegisterController" title="{!$Label.site.site_login}"> <apex:define name="body"> <center> <apex:panelGrid bgcolor="white" columns="1"> <br/> <br/> <apex:panelGrid width="758" cellpadding="0" cellspacing="0" bgcolor="white" columns="1" styleClass="topPanelContainer"> <br/> <apex:outputPanel layout="block" styleClass="topPanel"> <apex:panelGrid width="758" cellpadding="0" cellspacing="0" bgcolor="white" columns="2"> <apex:panelGroup > <h1>Don't have an account?</h1> <br/> <h2>Enter your email address to register</h2> <apex:form id="theForm" forceSSL="true"> <apex:panelGrid columns="2" style="margin-top:1em;"> <apex:outputLabel value="{!$Label.site.email}" for="email"/> <apex:inputText required="true" id="email" value="{!email}"/> <apex:outputText value=""/> <apex:commandButton action="{!registerUser}" value="{!$Label.site.submit}" id="submit"/> </apex:panelGrid> </apex:form> </apex:panelGroup> </apex:panelGrid> </apex:outputPanel> </apex:panelGrid> </apex:panelGrid> </center> <br/> </apex:define> </apex:page>
How can i achieve this?
Thanks in advantage for any advice.
BR.
public String email { get; set; }
public void checkEmail()
{
if(!Pattern.matches('[a-zA-Z0-9._-]+@[a-zA-Z]+.[a-zA-Z]{2,4}', email))
{
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'Check your email'));
}
}
Call this method from your registerUser method.
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks
All Answers
public String email { get; set; }
public void checkEmail()
{
if(!Pattern.matches('[a-zA-Z0-9._-]+@[a-zA-Z]+.[a-zA-Z]{2,4}', email))
{
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'Check your email'));
}
}
Call this method from your registerUser method.
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks
This is great, i prefer validation server side.Thanks