• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Validator RegExp for Telephone

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I need a help to create a regular expression to validate telephone field with Struts Validator. The regexp should be very simple: 4 numeric digits, a "-" char, and again more 4 numeric digits. Ex: "3131-3131".

Any ideias?
 
Wagner Danda Da Silva Filho
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found this solution:

\d{4,4}-\d{4,4}

In struts validation.xml:

<field property="phone" depends="required,mask">
<arg0 key="client.phone"/>
<var><var-name>mask</var-name>
<var-value>^\d{4,4}-\d{4,4}$</var-value></var>
</field>



Wagner Danda
reply
    Bookmark Topic Watch Topic
  • New Topic