Solved

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

Posted on 2008-06-17
2
3,814 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
2 Comments
 
LVL 49

Accepted Solution

by:
Roonaan earned 100 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

829 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