Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

validation problem for cost : struts2

 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi good morning,
in my application i had to do validation for cost i m doing server-side validations..i used regex for cost..but im not getting validated can any one help me out..here is the code
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any help regarding my post
 
kranthi chamarthi
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It will be helpful if you provide us with what values your "field to be validated" can take and what values it shouldn't.
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if i enter numbers it should take and also take decimal numbers such as '5,5.0,0.50' and if i enter alpha-numeric it should not take i had done the code change as follows

errors.number---enter only number
can you suggest me how to change my code according to my need..
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i need is if i kept blank it should not throw error and also if i enter any thing other than numbers it should throw an error can any one suggest me how to do...
 
Sridhar Santhanakrishnan
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about this?

 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i tried what you suggested but im not getting validated..here is my jsp code and validation.xml file

 
Sridhar Santhanakrishnan
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I meant just the regex part of the expression. Try



Any regex must start with ^ and end with a $.
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i didnt got your point..i tried using js..its working if i implement in struts2 in <field-validatio> im not getting.....i had done the same in reg ^[0-9]*\.?[0-9]+$
here is the code
 
madhuri kunchala
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
any help regarding my post..i m not getting validated and if i left blank it should not throw an error..any help
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic