Snarfles
asked on
Spry text field validation - alphanumeric characters only with no set length
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
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});
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
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
Open in new window