• 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

validate a textarea using regex

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to validate the contents of a textarea using the following regex. I've had no trouble validating text fields using this regex but the textarea check always fails.
var chkPasswordQA = /^[A-Za-z]$/;
if (form.forgottenPasswordQuestion.value.search(chkPasswordQA) == -1) {
errmsg = errmsg+"\n"+(arrErrField.length+1)+". error ";
form action="go.jsp" method="post" name="form" onSubmit="return validate(this);"
textarea rows="3" cols="50" name="forgottenPasswordQuestion"></textarea>
[/CODE]
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try using match instead and I changed the regular expression slightly
var StrRE = /[^A-Za-z]/;
if(StrT.match(StrRE))alert('Error')
Eric
[ March 04, 2004: Message edited by: Eric Pascarello ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic