vaildating mixed numeric text string

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris

    vaildating mixed numeric text string

    How would I go about validating multiple textfields within the same
    form to ensure they start with either 1 or 2 numerical digits (from 8
    to 14) followed by 2 or 3 text characters eg. 8MN and 14ABC being
    acceptable?

    Thanks for the help!

    Chris
  • Lasse Reichstein Nielsen

    #2
    Re: vaildating mixed numeric text string

    chrismatchett@h otmail.com (Chris) writes:
    [color=blue]
    > How would I go about validating multiple textfields within the same
    > form to ensure they start with either 1 or 2 numerical digits (from 8
    > to 14) followed by 2 or 3 text characters eg. 8MN and 14ABC being
    > acceptable?[/color]

    Try this regular expression
    var re = /^([89]|1[0-4])[A-Z]{2,3}$/;

    You can test a field value against it:
    if (!re.test(field Ref.value)) {
    // do error handling
    }

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    Working...