Changeset 728


Ignore:
Timestamp:
Feb 11, 2010, 10:55:29 PM (10 years ago)
Author:
Dominic Hargreaves
Message:

change the validation to use Paul's more detailed method

File:
1 edited

Legend:

Unmodified
Added
Removed
  • freethepostcode.org/html/ruby/submit.rhtml

    r726 r728  
    55require 'net/smtp'
    66require 'dao.rb'
     7require 'sanity_check'
    78include Math
    89
     
    1920Got this data: <%=email%> says that <%=postcode1%> <%=postcode2%> is at <%=lat%>, <%=lon%><br>
    2021
     22%errs = sanity_check(postcode1 << " " << postcode2, lat.to_f, lon.to_f)
     23%unless errs.empty?
     24Sorry, the postcode you entered does not validate, or we think the
     25latitude/longitude are not correct for the postcode zone.
     26%exit
     27%end
     28
    2129%if lat > 65 || lat < 40.0 || lon > 2.5 || lon < -8
    2230  Looks like bad lat/lon values, please go back and try again.<br>
     
    3240%else
    3341  Sorry, your email address does not look good, please go back and try again<br>
    34 % exit
    35 %end
    36 <%
    37     if (postcode1.match(/[A-Z]\d/) ||
    38     postcode1.match(/[A-Z][A-Z]\d/) ||
    39     postcode1.match(/[A-Z]\d\d/) ||
    40     postcode1.match(/[A-Z]\w\d\d/) ||
    41     postcode1.match(/[A-Z][A-Z]\d[A-Z]/) ||
    42     postcode1.match(/[A-Z]\d[A-Z]/) ) && postcode2.match(/\d[A-Z][A-Z]/)
    43 %>
    44   Postcode looks reasonable :-)<br>
    45 %else
    46   Sorry, your postcode should be of one of these forms:<br>
    47     <br>
    48     LD DLL<br>
    49     LLD DLL<br>
    50     LDD DLL<br>
    51     LLDD DLL<br>
    52     LLDL DLL<br>
    53     LDL DLL<br>
    54     <br>
    55     Where L is a letter and D a digit, for example SW1A 0AA matches LLDL DLL<br>'
    5642% exit
    5743%end
Note: See TracChangeset for help on using the changeset viewer.