semangar (1) [Avatar] Offline
#1
I donwloaded the source code and I haven't been able to find the file zipcodevalidator.lzx ... where could I find it?

Thanks and regards

Samuel
nklein (33) [Avatar] Offline
#2
Re: zipcodevalidator.lzx
> I donwloaded the source code and I haven't been able
> to find the file zipcodevalidator.lzx ... where could
> I find it?
>
> Thanks and regards
>
> Samuel

> I donwloaded the source code and I haven't been able
> to find the file zipcodevalidator.lzx ... where could
> I find it?
>
> Thanks and regards
>
> Samuel

My sincere apologies, it appears that the "zipcodevalidator.lzx" file was inadvertently left out of the source code archive. We will be sure to fix this in the next update.

There is is actually another file also missing, which is an updated copy of the "library.lzx" file. This file includes the "zipcodevalidator.lzx" file so it doesn't have to be explicitly included. You will need to perform the following steps:

// Change to the directory where Laszlo is installed and finally to the validators
// directory
$ cd $LASZLO_HOME/lps/components/incubator/validators

// Backup the existing library.lzx file
$ cp library.lzx library.lzx.orig

// Add the following line prior to the </library> tag with your favorite editor to the
// library.lzx file
<include href="zipcodevalidator.lzx"/>

This listing will need to be cut and paste into a zipcodevalidator.lzx file within the $LASZLO_HOME/lps/components/incubator/validators directory.

This Message site doesn't appear to preserve formatting, so you will have to excuse its lack of white space.

======== zipcodevalidator.lzx ==================================

<library>
<include href="basevalidator.lzx" />

<class name="zipcodevalidator" extends="basevalidator">
<attribute name="trim" type="boolean" value="true" />

<attribute name="notzipcodeErrorstring" type="string" value="Invalid zipcode" />

<method name="doValidation" args="val"><![CDATA[ >
var valtext = getValueText(val);

if (required && valtext.length < 1) {
this.setErrorstring(this.requiredErrorstring);
return false;
}

var dash = valtext.indexOf("-");
if (dash > 0) {
var zips = valtext.split("-");
if (zips[0].length != 5 || this.isInt(zips[0])) {
this.setErrorstring(this.notzipcodeErrorstring);
return false;
}
if (zips[1].length != 4 || this.isInt(zips[1])) {
this.setErrorstring(this.notzipcodeErrorstring);
return false;
}
}
else {
if (valtext.length != 5 || this.isInt(valtext)) {
this.setErrorstring(this.notzipcodeErrorstring);
return false;
}
}
this.setErrorstring("");
return true;
]]> </method>

<method name="isInt" args="value"><![CDATA[ >
if (!isNaN(value)) return false;
if (value.toString().indexOf("."smilie < 0)
return true;
else
return false;
]]></method>
</class>
</library>

=====================================================