Results 1 to 2 of 2

Thread: How can I to control characters in an input text?

  1. #1
    Join Date
    Mar 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How can I to control characters in an input text?

    Hi,

    I'm don't want the character ',' be print in the input text box, but I can do it work. Here is the code

    function fieldNumber(objeto, e){

    if(window.event && e.keyCode == 188){ // this is the keycode for IE & Firefox
    keynum=e.keyCode;
    e.keyCode=0;
    return false;
    }else if(e.which =44){// this is the opera's keycode
    e.which = 0;
    return false;
    }

    return true;
    }

    <input type="text" name="pepe" onkeydown=" return fieldNumber(this, event)" />

    Could someone help me please?

    Any help is welcome.-

    Regards

  2. #2
    Join Date
    Jun 2007
    Posts
    543
    Thanks
    3
    Thanked 78 Times in 78 Posts
    Blog Entries
    1

    Default

    Code:
    <script type="text/javascript">
    function remove(o) {
    var i=document.getElementById(o.id);
    i.value=i.value.substring(0,i.length-1);
    }
    function fieldNumber(o, e){
    if(window.event && e.keyCode == 188){ // this is the keycode for IE & Firefox
    keynum=e.keyCode;
    e.keyCode=0;
    remove(o);
    }else if(e.which =44){// this is the opera's keycode
    e.which = 0;
    remove(o)
    }
    return false;
    }
    </script>
    HTML Code:
    <input type="text" name="pepe" id="pepe" onkeydown="fieldNumber(this, event)" />
    [Jasme Library (Javascript Motion Effects)] My Site
    /\/\@§†ê® §©®¡þ† /\/\@|{ê®
    There are 10 kinds of people in the world, those that understand binary and those that don't.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •