I am trying to validate textbox in struts2 application of Jsp page. It should accept alphanumeric or alphabet.
I have used following code in validation.xml file:
<validator type="requiredstring">
<param name="fieldname">productName</param>
<message>Please select product Name.</message>
</validator>
<validator type="regex">
<param name="fieldname">productName</param>
<param name="expression">^[,a-zA-Z0-9 ]*$</param>
<message>Product name should accept only in AlphaNumeric.</message>
</validator>
Field name: product Name
Valid Input: abcdABC123(Alphanumeric), abcABC(alphabet)
Invalid: 123(Numeric)
Can anyone please help me to solve this issue. Thanks in Advance.
Use this regex:
Please read about
MUST CONTAINexpression from here:http://www.mkyong.com/regular-expressions/how-to-validate-password-with-regular-expression/