View Full Version : Reload event after 4 digits entered - HELP!

08-07-2008, 03:28 AM
I am currently using onkeyup for the page to reload but what i need is for the user to enter in 4 digits before the onkeyup function kicks in.

How can i do this??? It is for a postcode field which reloads a suburbs drop list.

echo "Postcode: <input name='cat' type=text onkeyup=\"reload(this.form)\" value=$cat>";

//I need it to reload after 4 digits have been entered.


08-07-2008, 04:03 AM
This maybe?

echo "Postcode: <input name='cat' type=text onkeyup=\"i++if(i == 4)reload(this.form)\" value=$cat>";

08-07-2008, 04:37 AM
That's erroneous ninnypants.

Try this instead:

echo "Postcode: <input name='cat' type=text onkeyup=\"if(this.value.length>4)reload(this.form);else return false;\" value=$cat>";

08-07-2008, 04:40 AM
Sorry just remembered that Australian post codes are 3 to 4 digits long.
I will have to just add a button which reloads the suburbs in the drop list.

Or if i 4 digits are entered it is reloaded and the button dissapears but if 3 digits then the button stays and user presses it manualy.
Can i do that? Because there are only about 11 suburbs with the 3 digits.