Originally posted by Sagar Rohankar:
There is no good reason using both the type of validation in same JSP page,,
and one major difference is server side validation is done by java classes which resides on your server and client side validation you can perform on client side like, in JSP/HTML page using scripts !!
So based on you requirement , you either choose server side or client side validation.
Now if your action form bean is extends ActionForm , then you can override validate() method and perform validation on form field like ,pincode , telephone nos, and return specific ActionError ,(See API for details)..
Or post your action form bean code here !
[ July 01, 2008: Message edited by: Sagar Rohankar ]
Hello Sir,
I have done it.
I am sending my code,so please check it and suggest me that is right way or not.
1)
I put that code in Form Been Error Validation method.
if(!(pincode ==null || pincode.length()<1))
{ System.out.println("pincode:"+pincode);
if(pincode.length()!=6)
errors.add("pincode", new ActionError("error.invalid.pincode"));
}
2)I put that code in Action class
String pinno = ((CreateUserForm) form).getPincode();
int pincode=0;
try{
pincode=Integer.parseInt(pinno);
System.out.println("Pincode :: "+pincode);
}catch(Exception e){
ActionErrors errors = new ActionErrors();
errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.invalid.pincode"));
saveErrors(request,errors);
System.out.println("Exception cought :: Exception :: " + e);
return (new ActionForward(mapping.getInput()));
}
Sir, it is working fine But i want to know that i am right or not.
After your suggestion i will apply that process to all value in my project.