Page is a not externally linkable
typomaniac - 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.