The reason you can use a space is because you have . in there which does NOT mean the character . but 'anything', that is matching your spaces. Having a - in a character class un-escaped is definitely incorrect syntax as it's the range opperator for things like A-Z and a-z. The & thing is wrong because character classes only match individual characters and not sequences of characters. The reason your RE is not working right is because it has syntax errors in it. You need to fix those before it will work reliably. The class in my reply you quoted below is more correct to what you have ATM.

If you want to get this to work my advice would be to simplify it first, get the basics working and then start adding in suport for more special characters, testing as you go.

As I read your RE the pattern in English would be "A letter followed by any amount of letters, nubmers, spaces, new line characters and some allowed special characters". Hence the following would be my starting point and I would then start adding in the special characters, being careful to escape where needed:

<var-value>^[a-ZA-Z][\w\ \r\n]*$</var-value>

That will allow all letters, numbers, spaces, newline characters after the 
first character which must be a letter. You can then add the special characters 
you need. You will definitely need at least the following:

<var-value>^[a-ZA-Z][\w\ \r\n\.\-\(\)]*$</var-value>

Note that you MUST escape . and - or you will be getting a different RE than what you think you are getting. If you put in . without escaping it it means "anything" so your RE will still allow through the special characters you think you are blocking.

Regards,

Bart.

Sahil Gupta wrote:

Bart, the mask that I have been using is
<var-value>^[a-zA-Z]{1}[a-zA-Z0-9\n_,;?!;:[EMAIL 
PROTECTED]/\\()&amp;$%#*+=-]*$</var-value

And this allows me to use spaces, & , - and other special characters
mentioned above. Just that \n does not work here.

Regards,

Sahil Gupta


-----Original Message-----
From: Bart Busschots [mailto:[EMAIL PROTECTED] Sent: Thursday, March 30, 2006 5:02 PM
To: Struts Users Mailing List
Subject: Re: Struts Validation

Hi Sahil,

I'm 90% sure the problem here is that some more of the special characters in
your large character class need to be escaped out. Thing is I can't find any
details of the syntax for REs in the struts validator docs so I'm not sure
exactly which ones. At a guess I'd suggest the following:

<var-value>^[a-zA-Z]{1}[a-zA-Z0-9\n\r\
_,;?!;:[EMAIL PROTECTED]/\\()&$%#*+=\-]*$</var-value>

The character class only matches individual characters so &amp; should not
be intere like that. As long as &, the letters a, m and P and ; are matched
then &amp; will be fine. . is a special character in it's own right so to
represent an actual fulstop you need \. and - is certainly a special
character within a character class so it definitely needs to be escaped.
Your RE was also not allowing the space character and depending on your OS
new lines can also use the \r special character so I added \ (slash followed
by a space) and \r to the class.

Bart.



Sahil Gupta wrote:

The current mask that I am using is:

<field property="notes" depends="required,maxlength,mask">
        <arg0 key="label.approval.notes"/>

        <msg name="mask" key="message.mask.displayname" />
        <var>
                 <var-name>mask</var-name>
        
<var-value>^[a-zA-Z]{1}[a-zA-Z0-9\n_,;?!;:[EMAIL PROTECTED]/\\()&amp;$%#*+=
-]*$</var-value>
        </var>    
        <arg1 name="maxlength" key="${var:maxlength}" resource="false"/>
        <var>
                 <var-name>maxlength</var-name>
                 <var-value>250</var-value>
</var> </field> And if I input some text and along with that I press the Enter Key I get Validation Error message that I have mentioned in my ApplicationResources.properties file.

Eg: In the text box I gave the following:
Recommended (and then pressed enter)
And Verified.

When I entered the above text in the Text Box it gave the validation error message.


Regards,

Sahil Gupta

Extn : 233
Email : [EMAIL PROTECTED]
******************************************************************
NetEdge Computing Global Solutions Private Limited. A-14, Sector-7, NOIDA U.P. 201-301
Tel #  91-120-2423281, 2423282
Fax #  91-120-2423279
URL  http//www.netedgecomputing.com
******************************************************************
This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation.

-----Original Message-----
From: Bart Busschots [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 30, 2006 4:05 PM
To: Struts Users Mailing List
Subject: Re: Struts Validation

Can you show me the current version of your mask and a sample of an input it is rejecting?

Bart.

Sahil Gupta wrote:



Thanks Bart,
Yes, what you said was right, so I have changed \ to \\ to match \.
But still I am unable to allow \n in my Validation.
Regards,

Sahil Gupta


-----Original Message-----
From: Bart Busschots [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 30, 2006 3:39 PM
To: Struts Users Mailing List
Subject: Re: Struts Validation

OK, so your Regular expression is trying to match everything between the start (^) and the end ($) of your input and no where in it do you allow a new line character, hence it is failing. You need to allow \n in which ever part of the RE you are happy to have new lines appear in. At a guess I'd say you probably want them in the second character class. What I do also notice is that you seem to have some un-escaped special characters in your second character class. The most obvious one is a single \, that will not match \, to match \ you need \\.

Hope that helps,

Bart.

Sahil Gupta wrote:



Here is an example of the mask that I am using.

                <field property="notes" depends="mask,maxlength">
                    <arg0 key="label.approval.notes"/>
                                <msg name="mask"
key="message.mask.displayname" />
                    <var>
                                <var-name>mask</var-name>
        
<var-value>^[a-zA-Z]{1}[a-zA-Z0-9_,;?!;:[EMAIL PROTECTED]/\()&amp;$%#*+=
-]*$</var-value>


                        </var>    
                    <arg1 name="maxlength" key="${var:maxlength}"
resource="false"/>
                    <var>
                                <var-name>maxlength</var-name>
                                <var-value>250</var-value>
                        </var>

</field>

Regards,

Sahil Gupta


-----Original Message-----
From: Bart Busschots [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 30, 2006 2:54 PM
To: Struts Users Mailing List
Subject: Re: Struts Validation

Can you show us the mask you currently use and then we will have a better chance of being able to help.

Bart.

Sahil Gupta wrote:



Hi,

I have used Masking in Validations. I have a text area in which I have only restricted some special characters. But still if I press Enter while adding some text there I get an error message.

Can anyone tell me how to allow ENTER in mask.

Thanks

Regards,

Sahil Gupta

Extn : 233
Email : [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
******************************************************************
NetEdge Computing Global Solutions Private Limited. A-14, Sector-7, NOIDA U.P. 201-301
Tel #  91-120-2423281, 2423282
Fax #  91-120-2423279
URL  http//www.netedgecomputing.com
******************************************************************
This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation.






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]








---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to