Page 1 of 1

Disable Submit until 3 characters are entered

Posted: Wed Mar 17, 2010 3:22 pm
by simonmlewis
Hello. I don't know anything about writing Javascript, and cannot find anything online that does this.

I want to disable the 'submit' button until at least 3 characters have been entered into the form.

I suspect it must do this via a hidden count, but no idea how to do this. Can anyone please help?

Re: Disable Submit until 3 characters are entered

Posted: Wed Mar 17, 2010 5:04 pm
by Sofw_Arch_Dev
Simonmlewis,

unfortunately you're probably going to have to learn some Javascript and CSS. You want to leverage the onkeydown event on the input element in question.

Code: Select all

 
<input  ... onkeydown="myCharCounter();" .../>
 
That function is going to set the css display property of the aforementioned submit button. You'll use things like

Code: Select all

 
var obj= document.getElementById( 'mySubmitButtonId');
 
and then set the display css property accordingly. There are more advanced ways of doing this, but they require a basic understanding of JavaScript fundamentals which you should acquire first.

Re: Disable Submit until 3 characters are entered

Posted: Wed Mar 17, 2010 5:13 pm
by simonmlewis
Thanks. I have absolutely not a clue with javascript, so I am not really any further.

What would be useful is if i was shown how to do something, and explain what it is that is being shown.