regularexpressionvalidator "does not contain"

  • Thread starter Thread starter Kyle Morris
  • Start date Start date
K

Kyle Morris

so the challenge is how to create a regex that validates a control when it
doesnt contain particular words or phrases. I've used the validator plenty
of times to validate correct input in different formats but never like this
before.

the example I would give would be how to stop a filename field using a
particular file extension say .asp, .php, aspx, etc

I know how to validate so that it does contain it, but not how to validate
so that it doesnt contain it.

any help would be greatly appreciated.

Cheers!
Kyle
 
Hello Kyle,
so the challenge is how to create a regex that validates a control
when it doesnt contain particular words or phrases. I've used the
validator plenty of times to validate correct input in different
formats but never like this before.

the example I would give would be how to stop a filename field using a
particular file extension say .asp, .php, aspx, etc

I know how to validate so that it does contain it, but not how to
validate so that it doesnt contain it.

any help would be greatly appreciated.

Regex isn't the tool to use here. You're much better off with a customvalidator
with a javascript function and a serverside function or your own implementation
of IValidatorControl.

If you're willing to forego clientside validation you could use the following
expression (which isn't supported in javascript as far as I know)

^(?!(the|words|you|don't|like).)*$

Or if it's just the extention you're after:

^.*(?<!the|extentions|you|won't|allow)$
 
Back
Top