Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Spry text field validation - alphanumeric characters only with no set length

Posted on 2008-06-17
2
Medium Priority
?
3,871 Views
Last Modified: 2009-10-07
Hey

I have a 'job name' text field on a form which I need to ensure doesn't have any special characters in it. So I have the following code which accepts case insensitive alphanumeric characters. I have a whole bunch of different spry elements in the page and the code below works as it should. What I couldnt find on the documentation page (http://labs.adobe.com/technologies/spry/articles/textfield_overview/) was how to enable it to have any number of characters but still validate. For example the code below requires 3 characters exactly to validate. I want to have it so that 3 characters is the minimum but they can enter up to 255 characters. Additionally they should be able to enter a space.

Cheers
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "custom", {validateOn:["blur", "change"], pattern:"YYY", useCharacterMasking:true});

Open in new window

0
Comment
Question by:Snarfles
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 49

Accepted Solution

by:
Roonaan earned 400 total points
ID: 21802587
Just a wild guess, I haven't got to much knowledge on Spry, but found this article that suggests using regExpFilter: http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=72&catid=602&threadid=1348168&highlight_key=y&keyword1=pattern

var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "custom", {validateOn:["blur", "change"], regExpFilter:/^[a-z0-9 ]{3,255}$/i, minChars:1,maxChars:255,useCharacterMasking:true});
0
 
LVL 9

Author Comment

by:Snarfles
ID: 21803602
Your a legend!
Slight change to the code you posted, {3,255} wasnt needed and just set the minChars to 3 and now its working perfectly.
Thank you very much
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "custom", {validateOn:["blur", "change"], regExpFilter:/^[a-z0-9 ]*$/i, minChars:3,maxChars:255,useCharacterMasking:true});

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question