|
-
Oct 19th, 2009, 03:07 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] regular expression validator no dot
Hello does someone know where to get the regular expression validator that "." dot is not allowed but other characters are acceptable.
-
Oct 19th, 2009, 03:18 PM
#2
Fanatic Member
Re: regular expression validator no dot
Not tested but this may work
I generally use expressions from regexlib.com
-
Oct 19th, 2009, 03:26 PM
#3
Frenzied Member
Re: regular expression validator no dot
That is the one I would use too.
-
Oct 19th, 2009, 03:40 PM
#4
Thread Starter
Frenzied Member
Re: regular expression validator no dot
I did that but now.. any words inside are considered having dot *confused* I just want to limit the .dot
-
Oct 19th, 2009, 03:43 PM
#5
Frenzied Member
Re: regular expression validator no dot
You don't need other words, this says match everything BUT the dot.
-
Oct 19th, 2009, 03:45 PM
#6
Thread Starter
Frenzied Member
Re: regular expression validator no dot
But now I typed "Test" or anything else, it still considered wrong... I only want to display the error message when the user types "test.testing" or something that has dot in it.
-
Oct 19th, 2009, 04:00 PM
#7
Thread Starter
Frenzied Member
Re: regular expression validator no dot
This is for the regularexpression validator.. not sure if that is different than regular regular expression
-
Oct 19th, 2009, 04:14 PM
#8
Frenzied Member
Re: regular expression validator no dot
This expression ignores the dot that's all it doesn't report the dot it reports everything else.
-
Oct 19th, 2009, 04:21 PM
#9
Thread Starter
Frenzied Member
Re: regular expression validator no dot
So how can I resolve this then? I want the regular expression to accept everything but the "dot" ... am I making sense?
-
Oct 19th, 2009, 04:43 PM
#10
Frenzied Member
Re: regular expression validator no dot
See it depends on what your trying to do.
Is.This.Ok
Meaning should you get I,s,t,h,i,s,o,k
Or do you want to get the words as whole words? where exactly are you inputing this expression?
-
Oct 19th, 2009, 05:07 PM
#11
Thread Starter
Frenzied Member
Re: regular expression validator no dot
It's the asp.net regular expression validator control. I put it next to the user name text field. So if the user puts "Is.This.OK" it will say "Error, no period/dot character" then when the user removes "Is this ok", then the error should go away. But right now I am applying that [^\.], it still says wrong even though I put " is this ok"
-
Oct 19th, 2009, 05:27 PM
#12
Frenzied Member
Re: regular expression validator no dot
Well it would be wrong because it contains no dot. Your using it as a true/false value but that's not how reg-ex works intrinsically. I've never used that control but that would make sense since reg-ex finds patterns and not determines state.
See what that expression does is NOT find a period. That means it reports back everything that is NOT a period it doesn't report back true or false. You would be better of doing a string.contains(".") instead of a regular expression.
-
Oct 19th, 2009, 05:44 PM
#13
Thread Starter
Frenzied Member
Re: regular expression validator no dot
Then how come Email regular expression would work with that control?
-
Oct 19th, 2009, 05:46 PM
#14
Frenzied Member
Re: regular expression validator no dot
-
Oct 19th, 2009, 06:52 PM
#15
Thread Starter
Frenzied Member
Re: regular expression validator no dot
Can someone help? I really need that validation.. where is medhak1 and gep? LOL
-
Oct 19th, 2009, 07:02 PM
#16
Frenzied Member
Re: regular expression validator no dot
What happens if you but that regex in with Is.This.Ok?
You might just need to reverse the logic in that case you need [\.]
But I recon that controls works via a none or all case IE it would have to match everything. So consider the email addy, well that has everything always the same. IE you can make an expression that captures everything. But your capture is two ambiguous from what I know of it.
I would need an example of a good use and a bad use to write an expression.
-
Oct 19th, 2009, 07:03 PM
#17
Fanatic Member
Re: regular expression validator no dot
Try this in regular expression validator:
Code:
ValidationExpression="^[^.]*$"
-
Oct 19th, 2009, 07:08 PM
#18
Frenzied Member
Re: regular expression validator no dot
That works on my end no dots:
I had: ^[^.]*\b
I couldn't figure out the end assertion $ (Which is the end of line).
Rep for you!
-
Oct 19th, 2009, 07:22 PM
#19
Fanatic Member
Re: regular expression validator no dot
 Originally Posted by DeanMc
Rep for you!
Yesss.. they are always needed..
-
Oct 19th, 2009, 07:34 PM
#20
Thread Starter
Frenzied Member
Re: regular expression validator no dot
Oh rjv.. that's awesome that's what I am looking for; however, it looks like it only checks one dot... the second dot, it just ignored. Ex: Is.this.ok ... it doesn't throw error.
-
Oct 19th, 2009, 09:42 PM
#21
Fanatic Member
Re: regular expression validator no dot
That's surprising. It shows the validation error message in my test page. Here is the code:
markup
Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Validator.aspx.cs" Inherits="ForumQns_Validator" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox runat="server" ID="txtTest" ></asp:TextBox>
<asp:Button runat="server" ID="btnTest" Text="Test!" OnClick="OnTestClick" />
<asp:RegularExpressionValidator runat="server" ID="revTest" ErrorMessage="Invalid"
ControlToValidate="txtTest" ValidationExpression="^[^.]*$"></asp:RegularExpressionValidator>
</div>
</form>
</body>
</html>
Code behind (it's empty on purpose)
Code:
//removed using statements
public partial class ForumQns_Validator : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void OnTestClick(object sender, EventArgs e)
{
}
}
Can you create a new page with the above code and check if it works?
-
Oct 19th, 2009, 09:55 PM
#22
Fanatic Member
Re: regular expression validator no dot
I guess you are missing the * towards the end of regular expression.
-
Oct 20th, 2009, 02:12 AM
#23
Re: regular expression validator no dot
Hey,
Looks like I arrived to late to help out on this thread
Good work Dean and rjv_rnjn!!!
Gary
-
Oct 20th, 2009, 12:20 PM
#24
Thread Starter
Frenzied Member
Re: regular expression validator no dot
Dang... I swear yesterday wasn't working. Today after restart tthe machine, it decides to work kudos to Rjv.
-
Oct 20th, 2009, 02:41 PM
#25
Re: [RESOLVED] regular expression validator no dot
If in doubt, switch it off, and switch it on again 
Gary
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|