Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Text Box Validation in JSP

 
Niraj Jamun
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,

I have scenarion below
username txtfield
password txtfield

submit button

if username is not entered
error msg should be displayed in front of text field
username txtfield *please enter username

i want to do this in jsp and not in struts or any framework
anyone have idea regarding this.any custom tags or code you already have
 
Kumaravadivel Subramani
Ranch Hand
Posts: 171
Java Linux Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As a simple way just have hidden <td> which contains error message and make it display when the script finds user name field is empty when to submit the form.
 
Niraj Jamun
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kumaravadivel Subramani wrote:As a simple way just have hidden <td> which contains error message and make it display when the script finds user name field is empty when to submit the form.


Hi,
thanks for the reply
i just gave eg of username n password jsp
in my jsp i have many field for each field new TD is not a good solution
it will increase the logic in my code also
Do you know any custom tag which will solve my prblm?
 
William Flores
Ranch Hand
Posts: 32
Chrome Eclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Use jQuery to do this.
Have you ever tried it?
 
Niraj Jamun
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William Flores wrote:Hi,

Use jQuery to do this.
Have you ever tried it?


Hi,
No, I haven't used jquery
if possible can you give me code for eg username textfield
how to display error in jsp in front of username textfield.
 
Pondurai Singh
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
simple jsp coding
 
Niraj Jamun
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pondurai Singh wrote:simple jsp coding


Hi Pondurai,

Can you please attache the /customtable1 tld which you have referred in jsp?
customtable1.tld and the respective java file

Thanks
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic