struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Pelly <gpe...@esri.com>
Subject RE: Validation - Mask
Date Thu, 24 Mar 2005 02:12:26 GMT
Add a ^ to the beginning of the pattern. Try changing:
  <var-value>[^/$&amp;=]+$</var-value>
To
  <var-value>^[^/$&amp;=]+$</var-value>

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.

<script>
  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")) ;
</script>

Greg

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message