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 4 of 4
  1. #1
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,415
    Thanks
    269
    Thanked 32 Times in 31 Posts

    check that first position is not numeric

    Im trying to validate a name input. I do not want the first char

    charAt(0) to be numberic 0123456789

    dont care if the rest of the name has numbers i just have to make sure the very first char is not numeric.

    any ideas

    i wonder if i can do
    Code:
    value.indexOf.charAt(0)
    something like that
    Last edited by durangod; 11-28-2012 at 03:16 PM.

  • #2
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    Just check indexOf for integer. If the indexOf == 0, first character is an integer. If it's -1 or >1, all good.
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,142
    Thanks
    203
    Thanked 2,547 Times in 2,525 Posts
    Code:
    <script type = "text/javascript">
    var n = "2abcde";
    if (/^\d/.test(n)) {
    alert ("Name must not begin with a digit")
    }
    </script>

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • Users who have thanked Philip M for this post:

    durangod (11-28-2012)

  • #4
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,415
    Thanks
    269
    Thanked 32 Times in 31 Posts
    Excellent thank you both, Philip exactly what i needed thanks


  •  

    Posting Permissions

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