Validate Text box value against database 
July 1st, 2009, 04:41 PM
| | Member | | Join Date: Jun 2009
Posts: 34
| | |
Hi Team,
I have designed a dynamic form with number of elements, i am stuck with a requirement where i need your help.
The requirement is :
While a user fills out the form, one particular text box value (User ID) needs to validated against a database table to check whether the user ID exists in the database table called Table1. If the UserID does not exists then an error message should be displayed.
I am making use of ASP classic for form design , VBScript for database connectivity
and Java Script for form validation.
If someone could help me out in coding this requirement, that will be much appreciated.
Many thanks
Last edited by jhardman; July 1st, 2009 at 06:57 PM.
Reason: moved to the Q&A section
| 
July 2nd, 2009, 10:14 AM
|  | Expert | | Join Date: Oct 2008 Location: Bristol, United Kingdom
Posts: 138
| | | re: Validate Text box value against database
Hi Quote:
The requirement is :
While a user fills out the form, one particular text box value (User ID) needs to validated against a database table to check whether the user ID exists in the database table called Table1. If the UserID does not exists then an error message should be displayed.
| You would need to use AJAX to do what you want. I recommend jQuery as it makes this type of thing a breeze (and lots more besides).
Perhaps a better way is to only provide the user with the values they can use to begin with (via a prepopulated select box), that way they can not get it wrong.
If the UserID you talk about is related to the user actually using the system, you might seriously want to think about creating a login system instead as this poses all sorts of security and usability concerns.
Gaz
| 
July 2nd, 2009, 04:07 PM
| | Member | | Join Date: Jun 2009
Posts: 34
| | | re: Validate Text box value against database
It is an application already built in ASP (front end), JavaScript(form validation and several other conditions), and VBscript for connectivity.I am not used to AJAX coding, never worked on it.. So Is there a way that i can accomplish this requrement using VBScript??
Can we write the database connection string inside a VBscript FUNCTION() ?? Does this work??
| 
July 2nd, 2009, 04:39 PM
|  | Expert | | Join Date: Oct 2008 Location: Bristol, United Kingdom
Posts: 138
| | | re: Validate Text box value against database Quote: |
JavaScript(form validation and several other conditions), and VBscript for connectivity.I am not used to AJAX coding, never worked on it
| Then what's the problem, AJAX simply is JavaScript!
You would use the onChange event to trigger the AJAX call to a VBScript page which would check your database for you and return something.
Like I said before, using a library like jQuery, this task is simpler than you might think.
Gaz.
| 
July 2nd, 2009, 05:07 PM
| | Member | | Join Date: Jun 2009
Posts: 34
| | | re: Validate Text box value against database
Can you please send an example code per your note above..Because i am very new to this AJAX and haven't worked on it anytime...
| 
July 3rd, 2009, 11:01 AM
|  | Expert | | Join Date: Oct 2008 Location: Bristol, United Kingdom
Posts: 138
| | | re: Validate Text box value against database
I may knock up something later if I get time.
Did you consider this approach? : Quote: |
Perhaps a better way is to only provide the user with the values they can use to begin with (via a prepopulated select box), that way they can not get it wrong.
| Gaz
| 
July 7th, 2009, 02:35 PM
| | Member | | Join Date: Jun 2009
Posts: 34
| | | re: Validate Text box value against database
When the numbers are more than 1000 or more it is not possible to provide all the values in a drop down.. Rather we have to validate the value entered against the database. So i want someone to comeup with an idea as you did..
| 
July 7th, 2009, 04:09 PM
|  | Expert | | Join Date: Oct 2008 Location: Bristol, United Kingdom
Posts: 138
| | | re: Validate Text box value against database
You have really only two choices then:
1) Check the value once its been posted, though the form will be reset if you bounce the user back if it is wrong.
2) Use an AJAX technique to query the database as the form is filled.
If you don't understand what I mean by this it is very much like when you type in the Google search bar and it suggests values for you.
The only difference is that instead of displaying suggested values, you will simply not allow the form to submit and maybe unhide a div with a message in it.
Does that make sense?
Try searching for "AJAX search tutorial" or similar.
Gaz.
| 
July 7th, 2009, 04:35 PM
| | Member | | Join Date: Jun 2009
Posts: 34
| | | re: Validate Text box value against database
Makes sense.. I will try searching as you suggested. And if i give you the code can you edit it for me cos i am running short of time i need to complete my Academic project work by the end of this week.. I will start my search so that i can get something to fix this issue..Thanks
chandhu
|  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,662 network members.
|