From: laredotornado on
Hi,

Does anyone have code that detects if a field has been entered in PO
Box format? I'm trying to prevent users from entering PO Boxes for
shipping addresses.

Thanks, - Dave
From: Evertjan. on
laredotornado wrote on 24 apr 2008 in comp.lang.javascript:

> Does anyone have code that detects if a field has been entered in PO
> Box format? I'm trying to prevent users from entering PO Boxes for
> shipping addresses.

What country, what format?

If you ca give a reasonable definition of what is a PO-box string and what
is not, a regex test should be possible.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
From: laredotornado on
On Apr 24, 3:01 pm, "Evertjan." <exjxw.hannivo...(a)interxnl.net> wrote:
> laredotornado wrote on 24 apr 2008 in comp.lang.javascript:
>
> > Does anyone have code that detects if a field has been entered in PO
> > Box format?  I'm trying to prevent users from entering PO Boxes for
> > shipping addresses.
>
> What country, what format?
>
> If you ca give a reasonable definition of what is a PO-box string and what
> is not, a regex test should be possible.
>
> --
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)

The country is the United States. My understanding of a PO Box is
that it is of the form PO Box #### where "#" is a number between 0 and
9. But the number of numbers could be unlimited, I suppose and there
could be variation in how "PO Box" is written, e.g. if punctuations
are included somewhere within. - Dave
From: Paul Lautman on
laredotornado wrote:
> On Apr 24, 3:01 pm, "Evertjan." <exjxw.hannivo...(a)interxnl.net> wrote:
>> laredotornado wrote on 24 apr 2008 in comp.lang.javascript:
>>
>> > Does anyone have code that detects if a field has been entered in
>> > PO Box format? I'm trying to prevent users from entering PO Boxes
>> > for shipping addresses.
>>
>> What country, what format?
>>
>> If you ca give a reasonable definition of what is a PO-box string
>> and what is not, a regex test should be possible.
>>
>> --
>> Evertjan.
>> The Netherlands.
>> (Please change the x'es to dots in my emailaddress)
>
> The country is the United States. My understanding of a PO Box is
> that it is of the form PO Box #### where "#" is a number between 0 and
> 9. But the number of numbers could be unlimited, I suppose and there
> could be variation in how "PO Box" is written, e.g. if punctuations
> are included somewhere within. - Dave

Very simplistically the regex
/PO\s+Box\s+\d+/i
will work.

Try it out like this:
<script type="text/javascript">
<!--
var f = /PO\s+Box\s+\d+/i;
var q = 'Po Box 33';
alert(f.test(q));
// -->
</script>


From: Evertjan. on
laredotornado wrote on 24 apr 2008 in comp.lang.javascript:

> On Apr 24, 3:01�pm, "Evertjan." <exjxw.hannivo...(a)interxnl.net> wrote:
>> laredotornado wrote on 24 apr 2008 in comp.lang.javascript:
>>
>> > Does anyone have code that detects if a field has been entered in
>> > PO Box format? �I'm trying to prevent users from entering PO Boxes
>> > for shipping addresses.
>>
>> What country, what format?
>>
>> If you ca give a reasonable definition of what is a PO-box string and
>> what
>
>> is not, a regex test should be possible.
>>
>> --
>> Evertjan.
>> The Netherlands.
>> (Please change the x'es to dots in my emailaddress)
>
> The country is the United States. My understanding of a PO Box is
> that it is of the form PO Box #### where "#" is a number between 0 and
> 9. But the number of numbers could be unlimited, I suppose and there
> could be variation in how "PO Box" is written, e.g. if punctuations
> are included somewhere within. - Dave

t = 'pO box 123';

if (/^\s*po\s+box\s+\d+$/i.test(t)) alert('PO box detected');

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 | 
Pages: 1
Prev: Not showing focus
Next: The Latest Edition