0

Using javascript, i need a regular expression that DOES NOT allow user to enter following words in a text box ( CASE INSENSITIVE ). so user should not be able to enter these words no matter what the case is Apple, Orange, Banana, Peach

Only Alpha numeric values are allowed with Dot. Special characters are not allwoed except dot

Following is what i tried, but does not work.

"^([a-zA-Z0-9.]*|((?i)Apple|Orange|Banana|Peach|))$"

Example valid value

SomeValue 23.56

Example invalid Value

Apple 23.56

ATHER
  • 3,254
  • 5
  • 40
  • 63
  • `foo|bar` in a regular expression means it will match either `foo` or `bar`. So that expression will match either an alphanumeric string or one of the words. There's nothing in there to **exclude** anything. – Barmar Aug 19 '16 at 00:25
  • If you want to exclude something, you need to use a negative lookaround. – Barmar Aug 19 '16 at 00:26

0 Answers0