Iam looking for the user to enter 3 characters and they should be letters and not numbers and special characters
if(txt1.match('[A-Za-z]{3}')){}
Is the above if condition is correct ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use the
iregex flag to make the matching case insensitive and simplify the regex. Also, without^and$, any string containing three consecutive letters will match. You need to add^and$to match the beginning and end of the string respectively. Finally, if you don’t need to capture the text matched, you should use thetest()method of the regular expression object to get a simple Boolean value: