homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Looking for JavaScript to enable form submit button after X characters
Validate minimum content

 3:28 pm on Apr 10, 2009 (gmt 0)

Hi Folks...

Not a JavaScript expert here... but I've been looking for an example script that would validate text-area content by character count, not allowing the form to be submitted until a minimum of X characters had been typed.

Does anyone have any guidance on this one?

Thanks in advance.



 6:47 pm on Apr 10, 2009 (gmt 0)

Use the string length property of the element value. Something like ...
var el = document.getElementById('myTextArea'); 
if (el.value.length > 75) {
// good to go
} else {
// I need more information


 1:44 pm on Apr 13, 2009 (gmt 0)

// note that I'm using the $() shortcut here... because I'm lazy

var el = $('myTextArea');
var sb = $('mySubmitButton');

// have the behaviour trigger on keyup for best user responsiveness
// the length condition returns true or false.
// assign that to the "disabled" property of your submit button

el.onkeyup = function(){
sb.disabled = (this.value.length < 75);


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved