Web tier: servlets, JSP, Web frameworks: How to allow hyphen (-) in validation frame work

  1. Hi!
    I am using the validation frame work with sturts, to validate the input field for address I had given the mask in validation.xml as below:

    <field property="address" depends="required,mask">
    <arg0 key="agentProfileForm.address.NotEntered"/>
      <var-value>^[0-9a-zA-Z ',/#---]*$</var-value>

    My intention of using 2 hyphens (---) in the mask is to allow the character '-' as a valid value, but when I do this special chracters like @,#,$ etc are also considered as valid characters.

    How to allow hyphen '-' as a valid character?

    Thanks in advance.

  2. In a normal regexp...[ Go to top ]

    ...you have to use \- to escape the -.

    Hope that helps,

    René Zanner