- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2016 12:36 PM
Is there a way that I can have an end-user enter a sentence into a normal string field and that each first letter of each word is made to be uppercase?
For example:
Risk no governance impacts the business.
TO:
Risk No Governance Impacts the Business.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2016 03:30 PM
WORKING Enhanced version that ignores capitalizing articles of the title:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
var myText = newValue;
var myTextInTitleCase = toTitleCase(myText);
g_form.setValue('risk_name',myTextInTitleCase);
function toTitleCase(e){
var t=/^(a|an|and|as|at|but|by|en|for|if|in|of|on|or|the|to|vs?\.?|via)$/i;return e.replace(/([^\W_]+[^\s-]*) */g,
function(e,n,r,i){
return r>0&&r+n.length!==i.length&&n.search(t)>-1&&i.charAt(r-2)!==":"&&i.charAt(r-1).search(/[^\s-]/)<0?e.toLowerCase():n.substr(1).search(/[A-Z]|\../)>-1?e:e.charAt(0).toUpperCase()+e.substr(1)
}
)};
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2016 03:30 PM
WORKING Enhanced version that ignores capitalizing articles of the title:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
var myText = newValue;
var myTextInTitleCase = toTitleCase(myText);
g_form.setValue('risk_name',myTextInTitleCase);
function toTitleCase(e){
var t=/^(a|an|and|as|at|but|by|en|for|if|in|of|on|or|the|to|vs?\.?|via)$/i;return e.replace(/([^\W_]+[^\s-]*) */g,
function(e,n,r,i){
return r>0&&r+n.length!==i.length&&n.search(t)>-1&&i.charAt(r-2)!==":"&&i.charAt(r-1).search(/[^\s-]/)<0?e.toLowerCase():n.substr(1).search(/[A-Z]|\../)>-1?e:e.charAt(0).toUpperCase()+e.substr(1)
}
)};
}