Log in

View Full Version : Nothing happening when checking a value??



twQ
12-27-2009, 08:05 PM
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

bluewalrus
12-27-2009, 08:51 PM
No document.alert just alert.

So...


<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();">

twQ
12-27-2009, 08:58 PM
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.