Question

non-capital letters

What is the best way to force only uppercase letters to be entered in a field?

Like 0

Like

2 comments

For example you can use the attribute and trigger the method after the column value was changed. Something like:

attributes: {
			"UsrTestColumnValidator": {
				"dependencies": [
					{
						"columns": ["UsrTestColumnValidator"],
						"methodName": "setUsrTestColumnValidator"
					}
				]
			}
		},
 
...
 
methods: {
			setUsrTestColumnValidator: function() {
				var currentValue = this.get("UsrTestColumnValidator");
				var neededValue = currentValue.toUpperCase();
				this.set("UsrTestColumnValidator", neededValue);
			},
}

Once something is input in the column from the UI it will be automatically converted to upper case.

 

Another option could be adding a custom column validator and allow only upper case letters to be inserted. Here is the article that explains how to create a custom validator for the column.

 

Best regards,

Oscar

Not sure, but I believe setting the value in the change event will cause the change event to be fired again, creating a loop.

I usually do this by faking the uppercase in the input field using some CSS, then actually change it to uppercase just before it is saved, like this:

1) Add CSS to the page to display the value in upper-case by adding this to the input (this just fakes it being upper case until saved):

text-transform: uppercase;

Then, in the save I actually change the values to upper case (this actually changes the value to upper case so it is saved correctly):

save: function() {
    this.set("UsrMyField", this.get("UsrMyField").toUpperCase());
    this.callParent(arguments);
}

Ryan

Show all comments