formatting text input

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

    formatting text input

    Does anyone know where I can find example scritp for formatting text input?
    I want to have a text box where only legitiamte filesname under unix can be
    netered (no whitespace, only alphanumeric, must start alpha) -Ike


  • Evertjan.

    #2
    Re: formatting text input

    Ike wrote on 06 mrt 2004 in comp.lang.javas cript:
    [color=blue]
    > Does anyone know where I can find example scritp for formatting text
    > input? I want to have a text box where only legitiamte filesname under
    > unix can be netered[/color]
    [color=blue]
    > (no whitespace, only alphanumeric, must start alpha)[/color]

    testresult = /^[a-z][a-z0-9]*$/i.test(filename )

    what about a period [.] ?


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

    Comment

    • Ike

      #3
      Re: formatting text input

      I dont understand though....how do you incorporate that into a text element
      on a form? Thank You -Ike

      "Evertjan." <exjxw.hannivoo rt@interxnl.net > wrote in message
      news:Xns94A46A0 CE87D4eejj99@19 4.109.133.29...[color=blue]
      > Ike wrote on 06 mrt 2004 in comp.lang.javas cript:
      >[color=green]
      > > Does anyone know where I can find example scritp for formatting text
      > > input? I want to have a text box where only legitiamte filesname under
      > > unix can be netered[/color]
      >[color=green]
      > > (no whitespace, only alphanumeric, must start alpha)[/color]
      >
      > testresult = /^[a-z][a-z0-9]*$/i.test(filename )
      >
      > what about a period [.] ?
      >
      >
      > --
      > Evertjan.
      > The Netherlands.
      > (Please change the x'es to dots in my emailaddress)[/color]


      Comment

      • Evertjan.

        #4
        Re: formatting text input

        Ike wrote on 06 mrt 2004 in comp.lang.javas cript:[color=blue]
        > "Evertjan." <exjxw.hannivoo rt@interxnl.net > wrote in message
        > news:Xns94A46A0 CE87D4eejj99@19 4.109.133.29...[color=green]
        >> Ike wrote on 06 mrt 2004 in comp.lang.javas cript:
        >>[color=darkred]
        >> > Does anyone know where I can find example scritp for formatting
        >> > text input? I want to have a text box where only legitiamte
        >> > filesname under unix can be netered[/color]
        >>[color=darkred]
        >> > (no whitespace, only alphanumeric, must start alpha)[/color]
        >>
        >> testresult = /^[a-z][a-z0-9]*$/i.test(filename )
        >>
        >> what about a period [.] ?[/color][/color]
        [color=blue]
        > I dont understand though....how do you incorporate that into a text
        > element on a form? Thank You -Ike
        >[/color]

        [please do not toppost on usenet]

        That depends on what you want to achieve.
        I hope you try to experiment awith and learn something from this.

        <script>
        function test(x){
        unix = x.unix.value
        if(/^[a-z][a-z0-9]*$/i.test(unix)){
        // (no whitespace, only alphanumeric, must start alpha)
        return true // submit allowed
        }
        alert("Not an allowed string") // warning
        return false // submit prevented
        }
        </script>

        <form onsubmit="retur n test(this)">
        <input name=unix>
        <input type=submit>
        </form>

        IE6 tested

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

        Comment

        Working...