Filtering form data.

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

    Filtering form data.

    Good day to all.

    I have this problem in JavaScript. I have a form (textbox) which
    accepts a series of numbers in format 9999-9999-9. Now i want to
    filter all inputs to the textbox. let's say 1234-1234-1 is a valid
    input, 12345-123-2 is an invalid input. I had a sample in filtering
    email address. I used a filter on that one.

    Hope anyone in the group can help me in my problem.
  • Randy Webb

    #2
    Re: Filtering form data.

    Aionius wrote:
    [color=blue]
    > Good day to all.
    >
    > I have this problem in JavaScript. I have a form (textbox) which
    > accepts a series of numbers in format 9999-9999-9. Now i want to
    > filter all inputs to the textbox. let's say 1234-1234-1 is a valid
    > input, 12345-123-2 is an invalid input. I had a sample in filtering
    > email address. I used a filter on that one.
    >
    > Hope anyone in the group can help me in my problem.[/color]

    If you want to require ####-####-#, the simplest way is 3 input boxes,
    and you insert the dashes where you want them. Or, just one input box
    that allows 9 digits, then you split it like you want.


    --
    Randy
    comp.lang.javas cript FAQ - http://jibbering.com/faq

    Comment

    • Dr John Stockton

      #3
      Re: Filtering form data.

      JRS: In article <316f1337.04081 91502.3ff76744@ posting.google. com>,
      dated Thu, 19 Aug 2004 16:02:04, seen in news:comp.lang. javascript,
      Aionius <aionius@hotmai l.com> posted :
      [color=blue]
      > I have a form (textbox) which
      >accepts a series of numbers in format 9999-9999-9. Now i want to
      >filter all inputs to the textbox. let's say 1234-1234-1 is a valid
      >input, 12345-123-2 is an invalid input.[/color]

      /^\d\d\d\d-\d\d\d\d-\d$/

      <URL:http://www.merlyn.demo n.co.uk/js-valid.htm>

      If the data is supplied and used elsewhere as dddd-dddd-d, then it will
      be easier for the operative to insert it in that form; I would not
      choose to split it into three boxes.

      --
      © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
      <URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
      <URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
      <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: Filtering form data.

        Aionius wrote:
        [color=blue]
        > I have this problem in JavaScript. I have a form (textbox) which
        > accepts a series of numbers in format 9999-9999-9. Now i want to
        > filter all inputs to the textbox. let's say 1234-1234-1 is a valid
        > input, 12345-123-2 is an invalid input. [...][/color]

        if (/^\d{4}-\d{4}-\d$/.test(inputStr) )
        {
        // valid input
        }
        else
        {
        // invalid input
        }


        PointedEars
        --
        Better living through chemistry...

        Comment

        Working...