I need to search an input\'s value for all street abbreviations and replace with appropriate suffix. This is what I have so far:
jQuery(\'#colCenterAddress\'
One way to do this, is to loop through the val string, and if you see a word in the f array, replace it with its counterpart in the r array.
jQuery('#colCenterAddress').val(function(i,val) {
var f = ['Rd','St','Ave'];
var r = ['Road','Street','Avenue'];
var valArray = val.split(' ');
$.each(valArray, function(i,v){
var inF = $.inArray(v, f);
if(inF !== -1){
valArray[i] = v.replace(f[inF], r[inF]);
}
});
return valArray.join(' ');
});