Condition Issue with Length

22 views
Skip to first unread message

trojanfresh

unread,
May 3, 2012, 11:21:35 AM5/3/12
to ValidateThis

I am having trouble with length and getting validation to trip I am
using a conditions

<conditions>
<condition name="WeRequireCarrier"
serverTest="val(getcarrier_flat()) EQ 0 AND len(getcarid()) neq 0"
clientTest="$(&quot;[name='carrier_flat']&quot;).getValue() == 0;
&amp;&amp; $(&quot;[name='carid']&quot;).getValue().length != 0;" />
</conditions>

The Property
<property name="carrier_flat" desc="Carrier Flat Pay">
<rule type="required" contexts="*" condition="WeRequireCarrier" />
<rule type="numeric" contexts="*" />
</property>
Where if carrier_flat = 0 and carid has something in it. carrier_flat
is a text box should be numeric only and carid is a hidden field that
gets populate when someone selects from a drop down.

using firebug i can see that when i do try to submit carid has a
value.

problem is it always passes validation.

I have even tried to just

<conditions>
<condition name="WeRequireCarrier"
serverTest="val(getcarrier_flat()) EQ 0"
clientTest="$(&quot;[name='carrier_flat']&quot;).getValue() == 0;" /
>
</conditions>

No luck.

any ideas is it because the one field is hidden?

Is there a way to catch with a cfdump/abort on server side what
getcarrier_flat is before validating to see if values are being
passed? I would like at least server side validation to work if i
can't get client side.

John Whish

unread,
May 3, 2012, 11:27:44 AM5/3/12
to valida...@googlegroups.com
Try:

      <condition name="WeRequireCarrier"
           serverTest="val(getcarrier_flat()) EQ 0 AND len(getcarid()) neq 0"
           clientTest="$([name='carrier_flat']).getValue() == 0 && $([name='carid']).getValue().length != 0;" />
      </conditions> 

(I removed the &quot; and &amp; as they are not valid JavaScript)


--
You received this message because you are subscribed to the Google Groups "ValidateThis" group.
To post to this group, send email to valida...@googlegroups.com.
To unsubscribe from this group, send email to validatethis...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/validatethis?hl=en.


trojanfresh

unread,
May 3, 2012, 11:31:46 AM5/3/12
to ValidateThis
I received an error saying invalid xml. Is the json way better?

On May 3, 11:27 am, John Whish <john.wh...@googlemail.com> wrote:
> Try:
>
>       <condition name="WeRequireCarrier"
>            serverTest="val(getcarrier_flat()) EQ 0 AND len(getcarid()) neq
> 0"
>            clientTest="$([name='carrier_flat']).getValue() == 0 &&
> $([name='carid']).getValue().length != 0;" />
>       </conditions>
>
> (I removed the &quot; and &amp; as they are not valid JavaScript)
>

John Whish

unread,
May 3, 2012, 11:39:23 AM5/3/12
to valida...@googlegroups.com
Ah right sorry, you will need to escape the '&' with &amp; Can you try:

<condition name="WeRequireCarrier"
  serverTest="val(getcarrier_flat()) EQ 0 AND len(getcarid()) neq 0"
  clientTest="$([name='carrier_flat']).getValue() == 0 &amp;&amp; $([name='carid']).getValue().length != 0;" />

It does get confusing making it XML safe.

trojanfresh

unread,
May 4, 2012, 9:18:42 AM5/4/12
to ValidateThis
Okay I Turned ON Debugging and I am getting werid results.

<conditions>
<condition name="WeRequireCarrierPay"
serverTest="val(getCarrierFlat()) eq 0 AND len(getCarId()) eq 0"
clientTest="" />
</conditions>

<contexts>
<context name="Save" formName="TestFrm" />
</contexts>
<objectProperties>

<property name="CarId" desc="Carrier Flat Pay">
<rule type="required" contexts="Save"
condition="WeRequireCarrierPay">
</rule>
</property>
<property name="CarrierFlat" desc="Carrier Flat Pay">
<rule type="required" contexts="Save"
condition="WeRequireCarrierPay">
</rule>

</property>
</objectProperties>

For Now I am ignoring client side just focusing on serverTest

<tr>
<td>
#common.isErrorMsg(validationErrors,"CarId")#
<label
for="CarId">#common.isRequired(RequiredFields,"CarId")#Test</label>
<div class="ctrlHolder">

<input type="text" size="25" id="CarId"
value="#dispatchObj.getCarId()#" name="CarId">
</div>
</td>
</tr>
<tr>
<td class="tableHdrTxt">
#common.isErrorMsg(validationErrors,"CarrierFlat")#
<label
for="CarrierFlat">#common.isRequired(RequiredFields,"CarrierFlat")#Carrier
Flat Rate (Only Enabled When Broker Is Used)</label>
<div class="ctrlHolder">
<input type="text" size="15" id="CarrierFlat"
value="#dispatchObj.getCarrierFlat()#"
name="CarrierFlat">
</div>
</td>
</tr>

What I have is to fields with the same condition

Problem is that Carid runs the condition correct CarrierFlat Does Not

Even Though They are Running the same condition i get two different
results.

Can You Explain Why This Is Happening On Server Side? Its What I Do
Believe Is leading me into these problems where i think my serverTest
code is correct but its not running right. Thanks

On May 3, 11:39 am, John Whish <john.wh...@googlemail.com> wrote:
> Ah right sorry, you will need to escape the '&' with &amp; Can you try:
>
> <condition name="WeRequireCarrier"
>   serverTest="val(getcarrier_flat()) EQ 0 AND len(getcarid()) neq 0"
>   clientTest="$([name='carrier_flat']).getValue() == 0
> &amp;&amp; $([name='carid']).getValue().length != 0;" />
>
> It does get confusing making it XML safe.
>
Reply all
Reply to author
Forward
0 new messages