Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Regex question

Reply
Thread Tools

Regex question

 
 
Hailstorm
Guest
Posts: n/a
 
      08-20-2004
How can I control if "a textbox is empty or not" with regex validation? I
don't want to use required field validator because I have a masked textbox
control and it has "ValidationExpress" property.
For example, if I want to control if it's a time value, I use
"(([0-1][0-9])|([2][0-3]))[:]([0-5][0-9])" but it doesn't work when textbox
is empty. How can I solve this problem? I want user to fill this area.
And by the way, if I try to use a req field validator for this, my masked
textbox doesn't seem on validator's "Control To Validate" property although
it has been inherited from textbox control.


Waiting for your replies.

Sincerely


 
Reply With Quote
 
 
 
 
news.microsoft.com
Guest
Posts: n/a
 
      08-20-2004
I ran into this problem myself -- the validator does not check empty fields
(see below). I ended up inheriting the validator and changing the
client-side javascript to include my own validation function. The downside
is that I had to add that function to a custom WebUIValidation.js (ugh).

One thing you could do is do the validation on the postback, and then
trigger the validator (validator.IsValid = false).


Hope this helps,
Sam Fields

excerpt from WebUIValidation.js ...

function RegularExpressionValidatorEvaluateIsValid(val) {
var value = ValidatorGetValue(val.controltovalidate);

#### if length=0 arbitrary "yes" #####
if (ValidatorTrim(value).length == 0)
return true;
var rx = new RegExp(val.validationexpression);
var matches = rx.exec(value);
return (matches != null && value == matches[0]);
}


"Hailstorm" <nomail@> wrote in message
news:%(E-Mail Removed)...
> How can I control if "a textbox is empty or not" with regex validation? I
> don't want to use required field validator because I have a masked textbox
> control and it has "ValidationExpress" property.
> For example, if I want to control if it's a time value, I use
> "(([0-1][0-9])|([2][0-3]))[:]([0-5][0-9])" but it doesn't work when

textbox
> is empty. How can I solve this problem? I want user to fill this area.
> And by the way, if I try to use a req field validator for this, my masked
> textbox doesn't seem on validator's "Control To Validate" property

although
> it has been inherited from textbox control.
>
>
> Waiting for your replies.
>
> Sincerely
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How make regex that means "contains regex#1 but NOT regex#2" ?? seberino@spawar.navy.mil Python 3 07-01-2008 03:06 PM
String Pattern Matching: regex and Python regex documentation Xah Lee Java 1 09-22-2006 07:11 PM
Is ASP Validator Regex Engine Same As VS2003 Find Regex Engine? =?Utf-8?B?SmViQnVzaGVsbA==?= ASP .Net 2 10-22-2005 02:43 PM
Java regex imposture re: Perl regex compatibility a_c_Attlee@yahoo.com Java 2 05-06-2005 12:16 AM
perl regex to java regex Rick Venter Java 5 11-06-2003 10:55 AM



Advertisments