Convert first letter to uppercase on input box

后端 未结 8 1311
梦如初夏
梦如初夏 2020-12-11 04:38

JS Bin demo

This regex transform each lower case word to upper case. I have a full name input field. I do want the user to see that each word\'s first letter he/she

8条回答
  •  萌比男神i
    2020-12-11 05:29

    $('input').on('keyup', function(event) {
        $(this).val(function(i, v){
            return v.replace(/[a-zA-Z]/, function(c){
               return c.toUpperCase();
            })
        })
    });
    

    http://jsfiddle.net/AbxVx/

提交回复
热议问题