Click here to Skip to main content
15,895,142 members

Comments by François Wahl (Top 4 by date)

François Wahl 14-Aug-14 5:53am View    
If you have a string like this for example `var wordString = 'theWord anOtherWord MayBemoreWords';` you can split into an array of words like this: `var words = wordString.split(' ')` - resulting in: `["theWord", "anOtherWord", "MayBemoreWords"]`. You can then iterate through them making all words lowercase and the first character uppcase similar to this: `for(var i = 0; i < words.length; i++){words[i] = words[i].toLowerCase(); words[i] = words[i].charAt(0).toUpperCase() + words[i].slice(1);}` - then join the array back into a string adding `, ` (comma and space) between them as required, assigning the result back to the original source, similar to this: `wordString = words.join(', ')` - I hope this can help you in getting started.
François Wahl 14-Aug-14 4:20am View    
You could use a regex on a `keyDown` event of the textarea that cancels the input if invalid or you could let the user type in what they want and then format the text yourself by making all text lowercase then separate all text by space and capitalize each word's first character and append a `,` if it does not already exist - or similar.
François Wahl 14-Aug-14 3:53am View    
You should probably post any new questions as separate questions instead of posting a new question as a solution.
François Wahl 12-Aug-14 8:10am View    
Are there any errors visible in your debugger console?