0

I get the surname.Than I do error checking.

if (preg_match("/[\d]/",$surname)) {
     $surnameErr = true;
     } 

The error shown when number is input. However the symbols would not be validated. I ask how to validate all symbols?

Moveover, how to validate all types of country character name with checking no digit and symbols. Thanks.

CodeWithCoffee
  • 1,896
  • 2
  • 14
  • 36
user3056561
  • 79
  • 1
  • 8

2 Answers2

0

Reference

var unicodeWord = XRegExp("^\\p{L}[\\p{L} ']*$");

alert('The first Result(with symbol) Ру@сский = '+ unicodeWord.test("Ру@сский")); //false 

alert('The first Result(without symbol) 日本語 = '+unicodeWord.test("日本語")); //true
<script src="http://cdnjs.cloudflare.com/ajax/libs/xregexp/2.0.0/xregexp-all-min.js"></script>
Dimag Kharab
  • 4,439
  • 1
  • 24
  • 45
0

Try with following code .

 $pattern = '/[^a-zA-Z]/';
$surnameErr = preg_match($pattern,$surname);
   if($surnameErr==""){
       $surnameErr =true;
}else{
   $surnameErr =falsee;
}
Arshid KV
  • 9,631
  • 3
  • 35
  • 36