![]() |
Form validation
Hey, I'm curious, how can I check an input value and match it in the database with javascript?
Like for instance, we have a simple login form. Input username, input password. When they write the username nothing happens, but when they DEselect the input field of username, it instantly checks if the username exists in the database. Code:
<form action="" method="POST">But how do I check the values in the database with javascript? :S |
It looks like you're wanting to use an XMLHttpRequest in JavaScript to talk to a PHP script on your server. The PHP script will then check the database to see if the username exists and report back accordingly. Then the JavaScript will parse the response and change the innerHTML of the spans as appropriate. Or, in a more concise form, you're wanting to do an AJAX call.
I don't know your level of knowledge in this area but just let me say that if you're looking for a way for JavaScript (and only JS) to talk to the database, then you can't. But that doesn't mean the process is difficult. Since it makes the process a whole lot easier, can I ask if you have any experience with JavaScript frameworks (jQuery, Prototype, Mootools...) and if so which one(s)? For the sake of simplicity, it would probably be easier to guide you through your problem using one of the frameworks (that's their purpose, to make things easier!). |
I have no experience in jQuery, Prototype nor Mootools, however that's why I'm kinda asking, cause I want to learn :)
|
Bump >.< ........
|
| All times are GMT. The time now is 07:44 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0