form submit

JavaScript related questions should go here.
Post Reply
ashwood
Posts: 144
Joined: Thu May 12, 2011 7:17 am

form submit

Post 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
I would put a signature.. BUT, i don't have the time.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: form submit

Post 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.
Image
ashwood
Posts: 144
Joined: Thu May 12, 2011 7:17 am

Re: form submit

Post 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
I would put a signature.. BUT, i don't have the time.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: form submit

Post by jacek »

This is how to load the php file.
Image
Post Reply