struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Pelly <>
Subject RE: Validation - Mask
Date Thu, 24 Mar 2005 02:12:26 GMT
Add a ^ to the beginning of the pattern. Try changing:

That should work.

If you're not familiar with regular expressions, a ^ at the beginning of a
regexp matches the string starting at the beginning (just as the $ matches
at the end).  Without it, as long as _something_ comes before the forbidden
characters, the mask will return true.

To see the difference, paste this Javascript into an HTML doc.

  var pattern = /[^&$]+$/; //"this" will match in the regular expression
  alert (pattern.exec("this& is a Test")) ;

  var pattern = /^[^&$]+$/; //regexp will fail.
  alert (pattern.exec("this& is a Test")) ;


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message