• 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

how to make text field to accept only alphabets

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a First name Text field.I want to make this text field to accept only characters.
How to make this text field to restrict accepting numbers and special characters.
 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Shrikanth Nekkanti:
I have a First name Text field.I want to make this text field to accept only characters.
How to make this text field to restrict accepting numbers and special characters.



This is JavaScript query, not JSP. Google "javascript restrict input" and you'll get lots of discussions, scripts and other related resources to help you with this.

Here's a quick link: http://www.rgagnon.com/jsdetails/js-0084.html, it works for alphanumeric input but you can easily modify the regex to only leave out the numbers also.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Tarun Yadav:


This is JavaScript query, not JSP. Google "javascript restrict input" and you'll get lots of discussions, scripts and other related resources to help you with this.

Here's a quick link: http://www.rgagnon.com/jsdetails/js-0084.html, it works for alphanumeric input but you can easily modify the regex to only leave out the numbers also.



If it is important that only alpha characters get through, then this should also be validated on the server.

Starting with version 1.4, Java ships with a very robust regular expression package. Start by looking at the String.matches method.
 
Tarun Yadav
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ben Souther:


If it is important that only alpha characters get through, then this should also be validated on the server.

Starting with version 1.4, Java ships with a very robust regular expression package. Start by looking at the String.matches method.



True, should've mentioned that. Got to addressing the OPs immediate requirement :p
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As we spoke about at Delete all invalid characters of a string the optimal solution, is to enforce your logic in each of the three tiers of the system.
 
It sure was nice of your sister to lend us her car. Let's show our appreciation by sharing this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic