homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Spry Modification
Spry Modification

 5:11 pm on Oct 29, 2012 (gmt 0)

This involves Adobe.spry javascript but not being used with Dreamweaver.
First...javascript is not my cup but anyway this one looked simple enough so gave it a shot.
Wanting to validate certain fields for alpha characters only but Spry did not include that--they have just about anything else a person might need though
Looking at the .js file the first validation scenario is for integers which is:

'integer': {
characterMasking: /[\-\+\d]/,
regExpFilter: /^[\-\+]?\d*$/,
validation: function(value, options) {
if (value == '' || value == '-' || value == '+') {
return false;
var regExp = /^[\-\+]?\d*$/;
if (!regExp.test(value)) {
return false;
options = options || {allowNegative:false};
var ret = parseInt(value, 10);
if (!isNaN(ret)) {
var allowNegative = true;
if (typeof options.allowNegative != 'undefined' && options.allowNegative == false) {
allowNegative = false;
if (!allowNegative && value < 0) {
ret = false;
} else {
ret = false;
return ret;

Looked like a simple enough solution to modify the regex to /^[a-zA-Z]$/i but I guess that wasn't happening because as it caused the browser to do ignore my efforts.
Is there any way I could change this? I was going to just add another routine to the .js file and name it alpha or something.
The validation is only a server side complimentary thing and is backed with Perl but it does provide a nice convenience on the user end.



 7:11 pm on Oct 29, 2012 (gmt 0)

A quick Google found this in the Adobe forums [forums.adobe.com]:

var custom = new Spry.Widget.ValidationTextField("id", "custom", {
validation: function( value, options ){
return /[a-z]/gi.test( value ); // your validation


 10:36 pm on Oct 29, 2012 (gmt 0)

Thanx a million Fotiman--worked like a charm. I had passed right by that one because in the post at Adobe forums the question said it was looking for only allow
where I was looking for alpha only. That will teach me to search more venues next time. A good thing also though because anyone else in the same predicament can benefit from your post.
Does need modified a tad though because it will allow anything to be entered as is if an alpha char is included. Testing now with /^[a-z]$/


 11:29 pm on Oct 29, 2012 (gmt 0)

Ah, good catch. Nice modification. :)


 3:57 am on Oct 30, 2012 (gmt 0)

I'm back at being confused again--while adding the ^ at the beginning and $ at the end made it impossible to add anything but alpha characters it shows an error if more than one char is entered.


 5:42 am on Oct 30, 2012 (gmt 0)


that is zero or more alphas


 5:50 am on Oct 30, 2012 (gmt 0)

Thank you so much daveVk--that hit the nail on the head. Now I can sleep--been messing with this thing for hours since before the 1st post.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved