Created
March 25, 2021 17:29
-
-
Save mustafadalga/c117eb94b512549cac6315ca8878df3c to your computer and use it in GitHub Desktop.
Validate Full Name (Turkish characters are valid)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function validateFullName(name="") { | |
const regex= /^[A-Za-zşŞıİçÇöÖüÜĞğ ]+$/; | |
const fullName=String(name).trim() | |
let warning={ | |
status:true, | |
message: "" | |
}; | |
if (fullName.length==0) { | |
warning={ | |
status:false, | |
message:"Please enter your full name" | |
} | |
}else if (!regex.test(name)) { | |
warning={ | |
status:false, | |
message:"Please enter your name alfetically!" | |
} | |
} | |
return warning; | |
} | |
console.log(validateFullName(" Göktuğ Şimşek Oruç ")) | |
console.log(validateFullName()) | |
console.log(validateFullName(" Mustafa 2021 ")) | |
console.log(validateFullName("Mustafa 2021")) | |
console.log(validateFullName(2021)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment