How to add a suffix to the input value?

There is input, there you can enter for example 100, but you still have value to add the suffix "sm" or "%" and that would be if you change the number, its width, the suffix is also moved. How to implement it?
March 19th 20 at 09:09
2 answers
March 19th 20 at 09:11
It is best not to enter in the form of this suffix. He does not need it, do not strain the user of this.
Do you still then these dlinnye go to JS\PHP - substitute suffix there, and best of all it does not substitute for the stage record in the database, unless of course you write to. The way there will be initial data can for example store millimeters and on the output to convert them to meters (substituting a suffix to the view), it is more flexible.

I'll do it like this (Showing the user that need to enter sm, not steaming with the suffixes in the box):
March 19th 20 at 09:13
$('input').on('blur', function(){
$(this).val(parseInt($(this).val())+'cm');
})
This approach will have focus on the field by the user to move the current cursor on 2 values from the end, it will not be convenient, the suffix should not be there. =) - kip5 commented on March 19th 20 at 09:16

Find more questions by tags jQuery