Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 61338 invoked from network); 12 Oct 2004 10:45:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 12 Oct 2004 10:45:22 -0000 Received: (qmail 76985 invoked by uid 500); 12 Oct 2004 10:45:12 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 76921 invoked by uid 500); 12 Oct 2004 10:45:11 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 76905 invoked by uid 99); 12 Oct 2004 10:45:11 -0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: domain of oliverchua@softhome.net designates 66.54.152.27 as permitted sender) Received: from [66.54.152.27] (HELO jive.SoftHome.net) (66.54.152.27) by apache.org (qpsmtpd/0.28) with SMTP; Tue, 12 Oct 2004 03:45:09 -0700 Received: (qmail 29858 invoked by uid 417); 12 Oct 2004 10:09:03 -0000 Received: from charleston-.softhome.net (HELO softhome.net) (172.16.2.12) by shunt-smtp-out-0 with SMTP; 12 Oct 2004 10:09:03 -0000 Received: from Toffer ([203.177.12.179]) (AUTH: LOGIN oliverchua@softhome.net) by softhome.net with esmtp; Tue, 12 Oct 2004 04:09:01 -0600 Message-ID: <002901c4b043$9f1de350$04a8a8c0@Toffer> From: "Oliver Chua" To: commons-user@jakarta.apache.org Subject: [Validator] Javascript error when using validWhen Date: Tue, 12 Oct 2004 18:09:47 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N I have a select and a text field. The validation is that the text field is required if the selected option code is 'New'. Below is an xml fragment of the declaration in validation.xml: test ((groupingCode!="New") or (*this*!=null)) It produces a javascript function like this: function AddUnitForm_maxlength () { this.a0 = new Array("groupingName", "Grouping Name can not be greater than 20 characters.", new Function ("varName", "this.maxlength='20'; this.test='((groupingCode!="New") or (*this*!=null))'; return this[varName];")); } Whether the part "New" is changed to 'New'(singel quotes), The Internet Explorer javascript engine objects to it saying there should be a ; after the quote. The behavior in Internet Explorer is like this: After entering invalid values, a popup window will appear. After clicking Ok, there will be a javascript error and the page will be submitted. (This shouldn't be the case if javascript is on since the whole point of javascript validation is to reduce roundtrips.) Since the page has errors, the html:errors will be displayed. I tried escaping String, like so: ((groupingCode!=\'New\') or (*this*!=null)) but it turned out to become: this.test='((groupingCode!=\\'New\\') or (*this*!=null))'; and still causes errors during validation. The Validator section of the Struts documentation says String literals in single or double quotes are legal values in the expression. Is this somehow a limitation og the validwhen tag? As I haven't been able to find an example of comparing fields with literal Strings in the , I have no idea if there is a workaround for this. --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org