how to Validate Reqular Expression.

Posted by Jayakumars under ASP.NET on 2/11/2013 | Points: 10 | Views : 894 | Status : [Member] [MVP] | Replies : 2
hi

My Validation part like this

<asp:RegularExpressionValidator ID="UrlRefs" runat="server" ControlToValidate="urlName"
Display="None" ErrorMessage="Invalid Url Name" ForeColor="Red" ValidationExpression="http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&amp;=]*)?"
ValidationGroup="AddRecord"></asp:RegularExpressionValidator>

<asp:ValidatorCalloutExtender ID="val1" runat="server" PopupPosition="BottomRight"
TargetControlID="UrlRefs"></asp:ValidatorCalloutExtender>


here i need allow input like this only how will do this.

I need allow this only.
===========================
Ex:

1.http://welcome.com
2.www.welcome.com
3.http://www.welcome.com

Mark as Answer if its helpful to you


Responses

Posted by: Ankitsrist on: 2/11/2013 [Member] Starter | Points: 25

Up
0
Down
use this validate expression
ValidationExpression="(http|https)://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?"


Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: aswinialuri-19361 on: 2/11/2013 [Member] Starter | Points: 25

Up
0
Down
Hi
for this validation expression you get the
url
Validation Expression="^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&amp;%\$#_]*)?$"
or else if you need like
some one example.com means you will use this expression:
validation Expression="^(?("")("".+?""@)|(([0-9a-zA-Z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-zA-Z])@))(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,6}))$"

Thanks & Regards
Aswini Aluri

Mark as Answer if it helps you
Thanks&Regards
Aswini Aluri

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response