PHP Form - Validating user input WITHOUT submitting

Hi

I need to know if there is a way to check the value of a text box in a PHP form without the user clicking the SUBMIT button.

This would mean if the user is prompted for an email address, the code will need to check the address entered before the submit button is clicked.
I have looked at a bunch of javascript/PHP code and all of it requires a button be clicked before that text box value can be picked up.

Thanks

Maybe keyup… validates as user inputs each character

I agree with Scallio. Being told my input is invalid while I’m still in the process of typing it is kind of annoying.

I’d just go with a blur listener. It’s probably a required field, so ideally you should also validate when the submit button is pressed. This way if the user never attempts to enter an email (they never click the field, and therefore never blur), they will still see the error message before reloading the page.

Egad — are you already using a JS library on your page?

No offense, but that would be utterly annoying, since that would mean I’d get an error message about my e-mail address so long as haven’t reached the . and the first two chars (depending on the driving regex of course) of the TLD yet …

another option is to to put an onchange on the email input box which then validates the structure of the email address and/or sends an AJAX request to the server to see if the email address already exists in the database immediately after the entry in the input box is changed.

Add a listener to one of the many JavaScript events (blur?), when invoked check the field.