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
yaramareddy radhikayaramareddy radhika 

How can we validate a Name field in VF page, It has to error when we enter Number or special symbols in name field? can any please tell me the code for this scenario.

Best Answer chosen by yaramareddy radhika
Rohit B ☁Rohit B ☁
Hi Yaramareddy,
You can write javascript/jquery for the same need.
Here is the Javascript code for your need :-
 
function allLetter(inputtxt)
  {
   var letters = /^[A-Za-z]+$/;
   if(inputtxt.value.match(letters))
     {
      return true;
     }
   else
     {
     alert("message");
     return false;
     }
  }

It will check only for letters and returns true/false based on the result.
Hope it works for you.. :)

All Answers

Rohit B ☁Rohit B ☁
Hi Yaramareddy,
You can write javascript/jquery for the same need.
Here is the Javascript code for your need :-
 
function allLetter(inputtxt)
  {
   var letters = /^[A-Za-z]+$/;
   if(inputtxt.value.match(letters))
     {
      return true;
     }
   else
     {
     alert("message");
     return false;
     }
  }

It will check only for letters and returns true/false based on the result.
Hope it works for you.. :)
This was selected as the best answer
yaramareddy radhikayaramareddy radhika
Can't we achieve this through Apex class without jquery/javascript?