Page 1 of 1

form submit

Posted: Sat Sep 24, 2011 12:26 pm
by ashwood
okay so ive got a form.. now i want the user to type the username in the form and click send email.. so they do but i want a php file in the background doing some checks because say the username is correct then i want a div to slide down at the top of the page saying Email Sent. if the username is incorrect then i want it to say Incorrect Username. just like that i no its jQuery but ive been thinking abot it all nite and cant think how i would go about it.

thanks

Re: form submit

Posted: Sat Sep 24, 2011 1:58 pm
by jacek
You can use onblur, which is when the user focuses on something else, like the next input box
var username_input = document.getElementById('username_input');

username_input.onload = function(){
    // do AJAX check
}
And for how to do the AJAX check, look here

Also, there is a better way then using username_input.onload that is more standard compliant, but I have forgotten it and my local server where all my code is, is not plugged in yet.

Re: form submit

Posted: Sat Sep 24, 2011 4:00 pm
by ashwood
jacek wrote:You can use onblur, which is when the user focuses on something else, like the next input box
var username_input = document.getElementById('username_input');

username_input.onload = function(){
    // do AJAX check
}
And for how to do the AJAX check, look here

Also, there is a better way then using username_input.onload that is more standard compliant, but I have forgotten it and my local server where all my code is, is not plugged in yet.

i dont get this at all.. why cant it just be where a php file loaded in the back does the check

Re: form submit

Posted: Mon Sep 26, 2011 4:51 pm
by jacek
This is how to load the php file.