Hi there, I did a search but could find anything I could really grasp. I am VERY new to javascript, and just finished reading my first book on it- so please be patient if I seem ignorant (I am).
I have been making a shoutbox as a personal challenge for a CMS, and have managed to make it work fine except users can post an 'empty' post by hitting the spacebar.
Here is the code I am currently using in the head of the template:
and this is in the body of the template:Code:<script type="text/javascript"> function formCheck(el){ if(el.value == ''){ alert('Please Enter Something to Post!'); el.focus(); return false; } else { return true; } } </script>
Now, I must stress that I pretty much understand this, but I had someone help me out a bit a while ago.Code:<form method="post" action="#xarModUrl('shouter', 'admin', 'create')#" onsubmit="return formCheck(document.getElementById('shout'));"> <p><input style="font-size:10px;" type="text" id="shout" name="shout" size="20" /></p> <p><input type="hidden" name="oldurl" value="#$oldurl#" /></p> <p><input style="margin-top: 5px; font-size: 10px;" type="submit" name="submit" value="#$shoutbutton#" /></p> </form>
Anyways, all works well if someone enters text-- it posts, and if someone just hits enter the alert window pops up. However, if someone hits the spacebar, an 'empty' post is submitted.
I appreciate any help you may offer. Again, my apologies if this is a redundant post.
Thanks


Reply With Quote
here is a real basic one to help you get started...
Bookmarks