File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Text Box Validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Text Box Validation" Watch "Text Box Validation" New topic
Author

Text Box Validation

Pranit Sonawane
Ranch Hand

Joined: Jul 29, 2011
Posts: 155

Hi all this is my code :
Registration form



and this is the jsp page with which the records will be stored into the database



what i want is if a new user trying to register and enters the same username which is already taken by someone else, he should get an error when he switches to he next text box of username.
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 507

Doing the database operations, inside the JSP.. A Strict NO. Java code inside JSP, was discredited 10 Years back. Move the Logic to Servlets.

As far as your problem is concerned. The solution may be like this.
In your registration.jsp, a small hyperlink, can be made next to username, as checkAvailabality. Once User clicks this, a AJAX operation will be made, that AJAX returns a status as username available or not available, so based on this, a appropriate div in a JSP will be updated. The backend also, as to do validation, before inserting into database and return back the error message, this is for the case if user doesn't use the checkAvailablity link, and just clicks Submit.


Regards, Prasad
SCJP 5 (93%)
Pranit Sonawane
Ranch Hand

Joined: Jul 29, 2011
Posts: 155

Thanks Prasad...great help!!!
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 507

Pranit Sonawane wrote:Thanks Prasad...great help!!!

Welcome Brother..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Text Box Validation
 
Similar Threads
when i retrive data from access it showing empty page in tomcat
Retrieve data from other server using JavaScript
Error 500 in root causes saying not enough value error
JDBC code with type 1 driver not working
ArrayIndexOutOfBoundsException