Validation expression for telephone number including hypens? - asp.net

I am using ajax mask for entering telephone number and now I want to validate the telephone number too. but I don't know what will be the validation expression to use with it.I have tried some but all vain. So please help me as soon as possible.I want to validate the number like 999-999-9999. Thank You

try this one
\d{3}-\d{3}-\d{4}

^[01]?[- .]?\(?[2-9]\d{2}\)?[- .]?\d{3}[- .]?\d{4}$

Related

asp.net email validation regex

I want to validate email in asp.net RegularExpressionValidator where email id is
abc
abc.def
abc_def
I have tried
[0-9a-zA-Z]+([_]{0,1})|([.]{0,1})[0-9a-zA-Z]+
but the or condition doesn't work. It always fails for 2nd condition.
can anyone help me?
Put the second pattern inside a group and make it as optional.
^[0-9a-zA-Z]+(?:[._][0-9a-zA-Z]+)?$
DEMO
[0-9a-zA-Z]+[._]?[0-9a-zA-Z]*
You can simply do this instead.See demo.
https://regex101.com/r/cK4iV0/31
For yours to work you can do
[0-9a-zA-Z]+(?:(?:[_]{0,1})|(?:[.]{0,1}))[0-9a-zA-Z]*
See demo.
https://regex101.com/r/cK4iV0/32

How do I validate a zip code in visual basic?

I am supposed to use the regularExpressionValidator to verify a ZIP code for a basic webpage I'm making. If the Zip code is valid, the submit button's click event procedure should display the message "Your ZIP code is" followed by the ZIP code and a period.
I don't know how to do an "if" statement to check to see if the zip is valid or not
**Why does the value = 0 when I enter 60611-3456
...don't know how to do an "if" statement...
You were assigned to use a RegularExpressionValidator, and this sounds like homework. If so, it also sounds like the purpose of the assignment is to make this happen without writing any if statements at all.
The validator controls have a feature where a postback event will not occur if validation fails. You use a correct regular expression with a correctly configured validator control, and the code that shows the "Your zip code is..." message will never run. Configuring the validator control is the point of the assignment; you need to do that part on your own. But finding an acceptable regular expression is a distraction from the real learning, and so I don't mind just giving that to you:
^\d{5}(-\d{4})?$
The issue is that your regular expression indicates the four digits must exist if you have the dash. Generally that would be okay but since you're using an input mask the dash always exists, even when it's only five digits. Try the following expression.
ValidationExpression="\d{5}-?(\d{4})?$"
Hope it helps.

JMAIL: Multiple Recipient

Does JMail accepts delimiter(;) or comma(,) as a separator between different email address like CDO.Message.
For example, we can write,
Mail.To="a#a.com,b#b.com" in CDO.Message.
Does the same is valid for JMAIL like the one below.
jMail.AddRecipient ("a#a.com,b#b.com")
I know we can add multiple recipients by calling the AddRecipient again and again but my question is can we do it in a single line like in CDO.Message?
yes you can add multiple recipients by calling the AddRecipient
Yes, you can.
I spent some time figuring this out as well. I tried the recommended array() of recipients but that did not seem to work. The only thing which worked for me so far was a properly formatted multiple recipient string:
$jmail->addRecipient('recipient1#site.com','recipient2#site.com','recipient3#site.com');
Please note the ["] markup. If you replace the ["] with ['] it will not work. It's little "delicate" this way :)
I am using jMail with PHP/COM extension but I am sure you can reuse this principle for ASP or any other language.
I hope this helped.

Validation for TextBox For a User Form

In my User Registration Form, I want my user address text box to accpet alphanumeric as well as special character but should not contain only numeric or special character.
I am currently using regular expression validator ,what regular expression i can use.
Or Is there any different solution for that.
Regards
Here you go.. I have used it at one place, and works pretty well.. just provide your acceptable characters and you are good to go
http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/FilteredTextBox/FilteredTextBox.aspx
You mean from your question that a string of alphabets is a must right ?

validation on weight in asp.net?

can i get validation on weight which can take decimal values and also integer.
suppose if i enter 60 it has to accept and if i enter 60.50 it has to accept (60.1..etc)
but not characters. Thank you.
Use regular expression validator to constrain input.
Positive Decimal: (^\d*\.?\d*[1-9]+\d*$)|(^[1-9]+\d*\.\d*$)
How To: Use Regular Expressions to Constrain Input in ASP.NET
you can use compare validator and use type double and operator data type check. it will work for you.
Ok try number two since I misunderstood your question :)
Use a RegularExpressionValidator and use the following expression:
^\d+\.?\d*$
Seems to match any number with as many decimal places as you allow.

Resources