Javascript validation code for textbox on press event

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • salo
    New Member
    • Mar 2007
    • 18

    Javascript validation code for textbox on press event

    Can anybody say me for writing javascript code for textbox key press event such a way that it should allow only alphabets,dot and spaces
  • sani723
    New Member
    • Feb 2007
    • 117

    #2
    this can help you. http://www.thescripts. com/forum/thread148144.ht ml

    Comment

    • sani723
      New Member
      • Feb 2007
      • 117

      #3
      and also check this http://www.merlyn.demo n.co.uk/js-valid.htm

      Comment

      • sani723
        New Member
        • Feb 2007
        • 117

        #4
        and this http://www.thescripts. com/forum/thread149058.ht ml

        Comment

        • chinnasrihari
          New Member
          • Mar 2007
          • 5

          #5
          Hi,

          If you wanna Regular exp, i can help you.
          Can i have your requirement.

          Chinna

          Comment

          • salo
            New Member
            • Mar 2007
            • 18

            #6
            Originally posted by chinnasrihari
            Hi,

            If you wanna Regular exp, i can help you.
            Can i have your requirement.

            Chinna
            i have return java script code for textbox ...this is code...it allows only aphabets...but i wat to allow space and dot....wat will be the code.....


            <script>
            function EnsureNumeric()
            {
            var a = window.event.ke yCode;
            //alert(a);
            if((a >= 97 && a <= 122) || (a >= 65 && a <= 90))
            return true;
            else
            return false;
            //alert(window.ev ent.keyCode);
            //a = 97; z = 122; A= 65; Z= 90
            }
            </script>
            <body>
            <input type="text" name="test" onkeypress="ret urn EnsureNumeric() ;">
            </body>

            Comment

            • datttanand
              New Member
              • Mar 2007
              • 19

              #7
              Originally posted by salo
              Can anybody say me for writing javascript code for textbox key press event such a way that it should allow only alphabets,dot and spaces


              write in the reguler exp validator
              following expression
              \w+

              Comment

              Working...