My Bad, there's another scenario when this field will validate. When reason != 'friend'

Better expression:

<param name="expression">(reason != 'friend') or ((reason == 'friend') and (friendEmail != null) and (friendEmail.trim().size() > 0))</param>

Eric

On Jul 19, 2007, at 1:33 PM, Eric Rank wrote:

Hi Matt,

I tried out your scenario, and I think I found the problem. In my test, it also validated when I left the friendEmail field blank. It seems that the value of friendEmail is not null, but an empty string. To solve the problem, I added another clause to check for String length. After that, it triggered the field error as desired. This is what worked for me.

<validators>
  <field name="friendEmail">
        <field-validator type="fieldexpression">
<param name="expression">reason == 'friend' and friendEmail != null and friendEmail.trim().size() > 0</param>
            <message>Please provide your friend's email</message>
        </field-validator>
    </field>
</validators>


Eric.


On Jul 19, 2007, at 10:40 AM, mraible wrote:

If you're right, I'd expect the following expression make friendEmail
required when the "friend" reason is checked (it's a radio button):

reason == 'friend' and friendEmail != null

However, if I check friend and don't fill out the e-mail address, it still passes validation. Based on the error message I'm getting in my logs (see below), I'm guessing that I need to do some sort of "friendEmail ! = null"
check, but I'm already doing that.



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

Reply via email to