kwilliams Posted February 17, 2006 Share Posted February 17, 2006 I'm new to using Regular Expressions, but I'm trying to use them for form validation. Everything's going fine so far, except for names that contain an apostrophe (i.e. O'Dell).This article http://msdn.microsoft.com/library/default....paght000001.asp, states that this code:Regex.IsMatch(fname_form, "^[a-zA-Z'.\s]{1,40}$")"...constrains an input name field to alphabetic characters (lowercase and uppercase), space characters, the single quotation mark (or apostrophe) for names such as O'Dell, and the period or dot character. In addition, the field length is constrained to 40 characters.".But I'm getting this error when attempting to enter a name with an apostrophe:Expected token 'eof' found 'NAME'. 'o'-->dell<--'Huh? If anyone can let me know what I'm doing wrong, that would be great. Thanks. Link to comment Share on other sites More sharing options...
kwilliams Posted February 17, 2006 Author Share Posted February 17, 2006 I decided that it would be smart to replace any apostrophe's with a question mark anyway for future use, so I just added a replace function like this:lname_form = lname_form.replace("'","?")...and I'll then change it back when displaying the data on a web page or email. Now I'm good-to-go. Thanks:) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now