Hello does someone know where to get the regular expression validator that "." dot is not allowed but other characters are acceptable.
Printable View
Hello does someone know where to get the regular expression validator that "." dot is not allowed but other characters are acceptable.
Not tested but this may work
I generally use expressions from regexlib.comCode:[^\.]
That is the one I would use too.
I did that but now.. any words inside are considered having dot *confused* I just want to limit the .dot
You don't need other words, this says match everything BUT the 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.
This is for the regularexpression validator.. not sure if that is different than regular regular expression
This expression ignores the dot that's all it doesn't report the dot it reports everything else.
So how can I resolve this then? I want the regular expression to accept everything but the "dot" ... am I making sense?
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?
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"
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.
Then how come Email regular expression would work with that control?
I dunno to be honest!
Can someone help? I really need that validation.. where is medhak1 and gep? LOL
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.
Try this in regular expression validator:Code:ValidationExpression="^[^.]*$"
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!
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.
That's surprising. It shows the validation error message in my test page. Here is the code:
markupCode behind (it's empty on purpose)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>
Can you create a new page with the above code and check if it works?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)
{
}
}
I guess you are missing the * towards the end of regular expression.
Hey,
Looks like I arrived to late to help out on this thread :)
Good work Dean and rjv_rnjn!!!
Gary
Dang... I swear yesterday wasn't working. Today after restart tthe machine, it decides to work :) kudos to Rjv.
If in doubt, switch it off, and switch it on again :)
Gary