• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 329
  • Last Modified:

Text field with 2 word minimum

I am using the Spry framework within dreamweaver (cs4) to validate a html form.  I have a text field that must have 2 words in it to work properly.  It can have more than two.  I would like to allow for more than one space between words and spaces before the string if possible.  

Since the rest of the form is validated using Spry, the OnSubmit function of the form is not used, and per my understanding is blank for spry to work properly.  I have heard there was a way to use another script in tandem with spry to accomplish this.  

So to be clear, I just need to validate one text field in a form to have at least 2 words, without destroying the existing spry validation.  

Thanks!
0
Large_Farva
Asked:
Large_Farva
1 Solution
 
Michel PlungjanIT ExpertCommented:
http://labs.adobe.com/technologies/spry/articles/textfield_overview/index.html
http://forums.adobe.com/message/1956818
http://forums.asp.net/t/1529563.aspx/1

something like


function validatetextField(value, options) {
  return /^((\b[a-zA-Z]{2,40}\b)\s*){2,}$/i.test(value);
}

var sometextField = new Spry.Widget.ValidationTextField("someTextField", "custom", {pattern: null, validation: validateTextField, validateOn:["blur"]});


0
 
iGottZFrontend EngineerCommented:
the regex could be simpler:

return /^\w{2,}\s+\w{2,}/i.test(value);
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now