Field Validation ?

Results 1 to 3 of 3

Thread: Field Validation ?

  1. #1
    Sid Guest

    Default Field Validation ?

    I am using java to check form fields , i need to check that one field has entries equal to chr,chr,number,number,number,chr,chr<BR>ie TN23 6LZ<BR>As you can see its a postcode ( UK ) i have to check that it is a uk postcode for VAT checking.<BR>Can ya help a twit ?<BR>TIA<BR>Sid

  2. #2
    Dan Evans Guest

    Default Regular expressions will save the world

    I hope you mean JavaScript otherwise this won&#039t work :o)<BR><BR>var str = "AB12 3CD"<BR>str = str.replace(/s/g, ""); //Strip out the white space<BR>if (str.match(/^wwd{2,3}ww$/) && str.match(/^DDd{2,3}DD$/)) alert("Valid postcode");<BR><BR>The first line strips out any white space to give "AB123CD". It then looks for 2 letters followed by 2 or 3 digits followed by 2 letters, e.g:<BR><BR>AB1 2CD is valid<BR> AB12 3 C D is valid<BR>AB12 35C is not valid<BR>AB123 4CD is not valid<BR><BR>There was an answer a few posts down that gave a link to a Regular Expression explanation page which should explain WHY this works.<BR><BR>Hope this helps,<BR><BR>-Dan Evans<BR>

  3. #3
    Sid Guest

    Default Thanks

    Cheers m8ty i have been looking at regular expressions after reading that other post but i was finding it a bit difficult ( end of a long day , just been given notice to change this sitye after i got it working just right , bloody clients )<BR>Thanks again<BR>Sid

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts