Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    Member
    Join Date
    May 2003
    Posts
    92
    Member #
    1526
    is there a way to use javascript to see if the contents of a string are all alphanumeric caracters? I'm trying to make an email verifier that i think will be really powerfull, i just wanna now the smallest way to test a string if its all alfynumy

    Heres what i got so far
    <script language="JavaScript">
    function echeck(){
    var string = document.form.replyto.value
    //Slice email address into components
    var atpos = string.indexOf('@')
    var user = string.substring(0,atpos)
    var domain = string.substring(atpos+1,string.length)
    if (user==''){return false}
    //make sure domain contains a '.'
    if (domain.indexOf('.')==-1){return false}
    //and that it is not the last caracter
    if (domain.lastIndexOf('.')==1){return false}
    //or the first
    if (domain.indexOf('.')==1){return false}
    //make sure there is no '..' (could be a typo)
    if (domain.indexOf('..')!==-1){return false}
    return true
    }
    function validate(){
    if (echeck()){
    form.submit()}
    else{
    alert(" ATTENTION \n\nThe email address you entered is not in the \n required format.\nRemember it must be Alphanumeric and\n in the xxx@xxx.xxx format")
    }
    }
    </script>
    im slowly adding more functions as i think up ways people can screw it up. all you need to do is call a function that calls echeck. If echeck returns true, submit form, else alert user to fix email.

    Thanks for any suggestions,
    J
    If there is no god, then who pops up the next Kleenex?

  2.  

  3. #2
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    E-mail address can contain nonalphanumeric characters like _ and . (and of course @).

    Look up regular expressions in Javascript and use:
    /[a-zA-Z0-9_-]+@[a-zA-Z0-9-]+\.[a-zA-Z]+/

    (I think)
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  4. #3
    Member
    Join Date
    May 2003
    Posts
    92
    Member #
    1526
    Ok, i looked up regular expressions, and im confused out of my mind. all i want to do is see if a string includes any characters besides the leters, numbers, @ , and '.'

    Do you know how i would do that?
    If there is no god, then who pops up the next Kleenex?

  5. #4
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Search around for how to use regular expressions in Javascript (or, for that matter, what they are).

    They took me a week to learn but they're so incredibly useful now that I know them.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  6. #5
    Senior Member skrlin's Avatar
    Join Date
    Apr 2003
    Location
    Illinois
    Posts
    562
    Member #
    1063
    - Brian

  7. #6
    Member
    Join Date
    May 2003
    Posts
    92
    Member #
    1526
    thats exactly what i looked up. That stuff confuses the hook outa me though. I learn better from examples. could you show me a way that i could see if a string has any characters sides a-z and 0-9 and - and "." could you show me how to do that?

    O and ive stripped the address into 2 parts 1 before the @ and one after. so i dont want either to include the @ sign.
    If there is no god, then who pops up the next Kleenex?


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 08:44 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2020 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com