Validating special characters

Rated 4.57/5 based on 712 customer reviews

I also need to validate if someone enters the Ampersand sign, and the pound sign.I can't figure out how to allow for validation of the & and #. Below is my current regular expression var char Validation = new Regex(@"^[a-z A-Z]"); You probably also want to tack on the "end of string" marker as well ( $ ). Hey I tried what you suggested and it does not work? var validator = new Regex(@"^[a-z A-z&#]"); if(validator.Form validation is an important to any website programming.If you own a website, it is then common that you have a contact form or any other form for registration, login and so on.It is necessary to do a server side and client side validation of the form before someone hits the submit button.Otherwise, the form reaching you may have junk data and inappropriate contents.Validating a HTML form for special characters is something which has been a concern for programmers and web designers.

His other interests are Linux, Machine learning, Wordpress, etc.If you don't, then your regex is only testing the start of the string, and any junk that comes at the end of the string isn't considered by your regex. If I pass in other charactrers like_ %^() the validation passes. Is Match(Text B Well first, you are only testing on the first character of a string (if you want to test on multiple you have to specify as such). i)[a-z&#]*, tells the regular expression parser to start at the beginning of the string and match, case insensitively, a single character in [a to z, & and #] between zero and an unlimited number of times.The next problem is that your usage of Is Match will return true, even if the entire string does not match the regular expression.-saige- Thanks Saige, I guess I am even more confused now. In a text box I want to allow someone to enter text, the letters a through z in upper or lower case. So this would be valid input: url#URL&Montage This would be invalid input: url*[email protected] Can you help me with figuring out the regular expression?I have tried many things but can't figure it out, even after reading about regular expressions.

Leave a Reply