Results 1 to 3 of 3

Thread: Nothing happening when checking a value??

  1. #1
    Join Date
    Dec 2009
    Location
    North Carolina
    Posts
    71
    Thanks
    13
    Thanked 3 Times in 3 Posts

    Default Nothing happening when checking a value??

    Ok, I must be more tired then I think because I'm having the most simple problem yet I can't for the life of me figure out whats going on! Ok all I wanna do is check a box to see if it's blank...

    JavaScript:
    /*global window: false */
    /*global document: false */

    function submitConForm() {
    var name=document.getElementById('name').value;

    if (name==='') {
    document.alert('You forgot to tell me your name!');
    return false;
    }

    else {
    document.alert('good to go');
    }
    }
    HTML:
    <input id="name" type="text" name="name" maxlength="20" class="txt">
    <br>
    <input type="submit" value="Send" class="btn" onClick="submitConForm();">
    I removed the whole form thing because I was trying to simplify this and now it's so simple yet I STILL can't figure it out. I click to submit the function and...nothing happens? I KNOW I'm missing something so incredibly simple I'm gonna feel like an idiot, but I just wanna solve this.

    Also incase the info helps, I ran it through JSLint, and W3C HTML checker thing. (Cause according to Firefox's spellcheck validator isn't a word, and there is no other word to mean that)

    Thanks,
    Tim

  2. #2
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    No document.alert just alert.

    So...
    Code:
    <script type="text/javascript">
    function submitConForm() {
    var name=document.getElementById('name').value;
    
    if (name==='') {
    alert('You forgot to tell me your name!');
    return false;
    }
    
    else {
    alert('good to go');
    }
    } 
    </script>
    <input id="name" type="text" name="name" maxlength="20" class="txt">
    <br>
    <input type="submit" value="Send" class="btn" onClick="submitConForm();">

  3. The Following User Says Thank You to bluewalrus For This Useful Post:

    twQ (12-27-2009)

  4. #3
    Join Date
    Dec 2009
    Location
    North Carolina
    Posts
    71
    Thanks
    13
    Thanked 3 Times in 3 Posts

    Default

    Thank YOU!!! It would be window anyways. I added that in an attempt to add every global earlier in my troubleshootin, and I am tired and put document. I do feel a bit stupid, but it works so I do NOT care.

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
  •