formfield requires 2 commas

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

    formfield requires 2 commas


    hello ng

    does anyone have an idea how to check in an input field,
    if the value contains exactly two commas?

    examples:
    "gaga,gogo,gugu " or ",,gagaggig i"

    any ideas?

    sascha




  • Evertjan.

    #2
    Re: formfield requires 2 commas

    Crescionini Sascha wrote on 22 jul 2003 in comp.lang.javas cript:
    [color=blue]
    > hello ng
    >
    > does anyone have an idea how to check in an input field,
    > if the value contains exactly two commas?
    >
    > examples:
    > "gaga,gogo,gugu " or ",,gagaggig i"
    >
    > any ideas?
    >[/color]

    s = "gaga,gogo,gugu ";
    n= s.replace(/[^,]+/g,"").length;
    alert(n);

    [the + speeds things up, says John S.]

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    • Evertjan.

      #3
      Re: formfield requires 2 commas

      Evertjan. wrote on 22 jul 2003 in comp.lang.javas cript:
      [color=blue]
      > Crescionini Sascha wrote on 22 jul 2003 in comp.lang.javas cript:
      >[color=green]
      >> hello ng
      >>
      >> does anyone have an idea how to check in an input field,
      >> if the value contains exactly two commas?
      >>
      >> examples:
      >> "gaga,gogo,gugu " or ",,gagaggig i"
      >>
      >> any ideas?
      >>[/color]
      >
      > s = "gaga,gogo,gugu ";
      > n= s.replace(/[^,]+/g,"").length;
      > alert(n);
      >
      > [the + speeds things up, says John S.]
      >[/color]

      O sorry, you wanted a test:

      s = "gaga,gogo,gugu ";
      if(s.replace(/[^,]+/g,"").length==2 )alert("Yes");


      --
      Evertjan.
      The Netherlands.
      (Please change the x'es to dots in my emailaddress)

      Comment

      • Crescionini Sascha

        #4
        Re: formfield requires 2 commas

        hi

        thank you very much, works great!!!

        greets
        sascha

        "Evertjan." <exjxw.hannivoo rt@interxnl.net > wrote in message
        news:Xns93C09B5 43A240eejj99@19 4.109.133.29...[color=blue]
        > Evertjan. wrote on 22 jul 2003 in comp.lang.javas cript:
        >[color=green]
        > > Crescionini Sascha wrote on 22 jul 2003 in comp.lang.javas cript:
        > >[color=darkred]
        > >> hello ng
        > >>
        > >> does anyone have an idea how to check in an input field,
        > >> if the value contains exactly two commas?
        > >>
        > >> examples:
        > >> "gaga,gogo,gugu " or ",,gagaggig i"
        > >>
        > >> any ideas?
        > >>[/color]
        > >
        > > s = "gaga,gogo,gugu ";
        > > n= s.replace(/[^,]+/g,"").length;
        > > alert(n);
        > >
        > > [the + speeds things up, says John S.]
        > >[/color]
        >
        > O sorry, you wanted a test:
        >
        > s = "gaga,gogo,gugu ";
        > if(s.replace(/[^,]+/g,"").length==2 )alert("Yes");
        >
        >
        > --
        > Evertjan.
        > The Netherlands.
        > (Please change the x'es to dots in my emailaddress)[/color]


        Comment

        Working...