Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2002
    Location
    Noblesville, IN
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts

    check that last character is not a period.

    how can i check that if an input field ends in a period (.), i throw up an alert.

    thanks.
    Ed Ventura
    Graphic/Web Designer
    www.blackwatercompany.com

  • #2
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    Here you Go:

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <script type="text/javascript" language="javascript">
    function formVal(){
    str=document.getElementById('box').value;
    checkp=str.charAt(str.length-1);
    if(checkp=="."){
    alert("No Period There Please");
    }

    }
    </script>
    <title></title>
    </head>
    <body>
    <form><input type="text" id="box"> <input type="button" value=
    "Submit" onclick="formVal();"></form>
    </body>
    </html>


    Basscyst


  •  

    Posting Permissions

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