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


i need the validation for the name should not contain numbers and special characters.

<apex:page controoller=""s>

<apex:pageBlockSectionItem >Name:</apex:pageBlockSectionItem>

<apex:pageBlockSectionItem ><apex:inputText value="{!name}" id="name"/></apex:pageBlockSectionItem>
<apex:pageblockButtons >
<apex:commandButton value="save" action="{!find}"/>

public class S
    public string name{get;set;}

<apex:Form id="Form_ID">
<apex:messages title="Errors Occured" styleClass="errorMsg" style="font-family:verdana,garamond,serif;" />
          <apex:pageBlock id="PageBLock_ID1" mode="edit">
              <apex:pageblocksection  columns="2"  collapsible="false">
	          <apex:pageBlockSectionItem >                        
	              <apex:outputLabel value="First Name" style="position:relative;float:left;"/>
		         <apex:outputPanel styleClass="requiredInput" layout="block" style="position:relative;left:2px;"> 
			<apex:outputPanel styleClass="requiredBlock" layout="block"/>
			     <apex:inputField value="{!AccountInfo.Name}"/>
	<apex:commandButton value="Save" action="{!SaveAccount}" reRender="Form_ID"/>         

public class AccountInfo
    public Account AccountInfo = new Account();
    public Account getAccountInfo()
        return AccountInfo;
    public void SaveAccount()
         if((AccountInfo.Name == Null || AccountInfo.Name == '')
             ApexPages.Message msgAddr = new ApexPages.Message(ApexPages.severity.Error,'Enter required fields');
	     insert AccountInfo;

 Hey, try this code..

Sridhar BonagiriSridhar Bonagiri



Use REGEX to validate for numbers and special characters in the name field.



Sridhar Bonagiri

If this post is your solution, kindly mark this as the solution and give Kudos.