mardi 15 septembre 2015

Ember helper to capitalize first letter on input

I am trying to create an Ember helper that when a user enters first and last name on input field it will capitalize the first letter of both names.

import Ember from 'ember';

export function capitalizeFirstLetter(string) {
 return string[0].toUpperCase() + string.slice(1, 0);

}

export default Ember.Helper.helper(capitalizeFirstLetter);

The above code capitalize every character of first and last name and only on output. It does not dynamically capitalize when user is typing. eg. feeling out the form with

<input value=firstName>john
<input value=lastName> smith 

On keyup it should automatically display John Smith under each field.




Aucun commentaire:

Enregistrer un commentaire