Is there a way add a text function that
1. Capitalizes the first letter of every word, and
2. Removes the spacing between each word
Example:
small dogs with big eyes = SmallDogsWithBigEyes
Thank you
Is there a way add a text function that
1. Capitalizes the first letter of every word, and
2. Removes the spacing between each word
Example:
small dogs with big eyes = SmallDogsWithBigEyes
Thank you
Hi David, Did you ever work out a text formula to remove spaces?
Thanks Derek. Yes I am asking if the text formula can do that.
Thank you for providing the javascript solution.
Are you asking for a text formula to do that, or javascript code to convert a phrase, for example, on submission of a form?
If the the latter, here is an example that could capitalize the first letter of every word, lowercase the remaining letter of each word, and then remove all spaces. This would go into your API Javascript section for the app. (It's turned on for all views, but you could set that up for your specific need)
/* -------------------------------- OUTSIDE FUNCTIONS TO ALL VIEWS ------------------------------------ */
/* ----------------------------------- RETURN PROPER CASE FORMAT -------------------------------------- */
String.prototype.formatString = function () {
var str, txt;
str = this.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
return str;
};
/* ------------------------------ END OUTSIDE FUNCTIONS TO ALL VIEWS ---------------------------------- */
/* --------------------------------------- APPLIES TO ALL VIEWS --------------------------------------- */
$(document).on('knack-view-render.any', function(event, view) {
/* --------------------------------- Proper Format for All Views ------------------------------------ */
//var myStr;
$(".kn-submit input[type=submit]").on("click", function() {
//Grab Field #1 value, convert to title case, and then remove all spaces, and insert value into Field#2
$("#field_2").val($("#field_1").val().formatString().replace(/\s/g,''));
return true;
})
});
/* ---------------------------------- End Proper format Script ---------------------------------------- */