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 6 of 6
  1. #1
    New Coder
    Join Date
    Oct 2005
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need Help on this script

    right mm i am kind of stuck on this bit am just learning html

    if (document.form1.vdfmm.value < 1&&document.form1.vdfmm.value > 12)
    {
    dAlert();
    }
    this works fyn but if i use

    if (document.form1.vdfmm.value < 01&&document.form1.vdfmm.value > 12)
    {
    dAlert();
    }
    the 01 doesnt seem to be counting how do i make it so it can recognise 01,02,03,04,05,06,07,08,09,10,11,12

    the 0 messes it up

    this is script is for a credit card validator if it helps you understand it better
    Last edited by Rudurk; 07-16-2006 at 03:55 PM.

  • #2
    New Coder
    Join Date
    Oct 2005
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Can i please also know how can i validate a email address

  • #3
    Super Moderator sage45's Avatar
    Join Date
    May 2002
    Posts
    1,064
    Thanks
    0
    Thanked 15 Times in 15 Posts
    This really should have been posted in the javascript area... I will move it there, however I will answer your question... The reason is that from a submission standpoint the leading 0 is stripped off as it is not needed...

    -saige-
    HTML & CSS Forum Moderator

    "If you don't know what you think you know, then what do you know."
    R.I.P. Derrick Thomas #58
    1/1/1967 - 2/8/2000

  • #4
    New Coder
    Join Date
    Oct 2005
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts
    so how can i make it so it will count 01? any ideas?

  • #5
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    You need to convert the value to a number.

    var mnth = parseInt (document.form1.vdfmm.value);
    if (mnth < 1 || mnth > 12) {
    dAlert();
    }

    The number cannot be both smaller than 1 and greater than 12.

    As for your question about validating an email address, I suggest you try Google
    or use the search feature of this forum.

  • #6
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,518
    Thanks
    3
    Thanked 506 Times in 493 Posts
    if (document.form1.vdfmm.value < 01&&document.form1.vdfmm.value > 12&&document.form1.vdfmm.value.length!=2)
    {
    dAlert();
    }
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/


  •  

    Posting Permissions

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