SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict lundberg's Avatar
    Join Date
    Mar 2003
    Location
    Sweden
    Posts
    370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Validating on onblur?

    Hello

    I've got this:

    <label for="fn">Firstname</label>
    <span id="fne"></span>
    <input name="firstname" id="fn" type="text" onblur="return checkFirstname()" />

    and then this:
    <script type="text/javascript" src="javascript.js"></script>

    and last this:
    checkFirstname()
    {
    x=document.theForm
    input=x.firstname.value
    if (input.length<1)
    {
    document.getElementById('fne').innerHTML = "Firstname is a required field."
    }
    }

    why isn't it working? =)

    Thanks in advance!

    Martin Lundberg
    Sweden

  2. #2
    SitePoint Addict
    Join Date
    May 2000
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:
    if (input.value.length<1)
    {
    document.getElementById('fne').innerHTML = "Firstname is a required field."
    }
    }


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
  •