Admin1676454018 Posted August 22, 2008 Share Posted August 22, 2008 Copy and paste everything below this line: // Edit the Field which to apply this function // Change the name of the Font that you want to use for numbers and letters. // If you use this Rule Inline, please be sure you style it Unique to the other fields, // the last font tag to be written is for letters and may not be correct for the next word. // You can get around this by styling the RuleName something totally unique and not used anywhere else. // var formatField = Field("address"); var fontNumber = "Courier New"; var fontLetter = "Helvetica"; ////////////////////////////////////////////////////////////////////////////////////////////////////// // DO NOT EDIT BELOW THIS LINE /////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////// // //initialize the variable //var formatThis = "201a Highway 101 #150"; //Call the Main function and pass it the Field to use. // return FormatAlphaNumeric(formatField); //create function for formatting function FormatAlphaNumeric(){ //check if Field is empty if (formatField){ //if Field is not empty do this //check if String contains a number if (HasNumber(formatField)){ //if a number in the string, replace the numbers with the following font tags //but also put the numbers back into place formatField = formatField.replace(/(\d+)/g,"<f name=\""+fontNumber+"\">$1<f name=\""+fontLetter+"\">"); return formatField; } else { //if no number in the string say this //return "The Variable formatThis has no number"; return formatField; } } else { //if Field is empty say this //return "The Variable formatThis is empty"; return formatField; } } //create function for checking a string for number, anywhere function HasNumber(testString){ var patternNumber = /\d/; return patternNumber.test(testString); } //create function for checking a string for letter, anywhere function HasLetter(testString){ var patternNumber = /\D/; return patternNumber.test(testString); } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.