Adding extra zeros in front of a number using jQuery?

后端 未结 14 1161
粉色の甜心
粉色の甜心 2020-11-30 02:45

I have file that are uploaded which are formatted like so

MR 1

MR 2

MR 100

MR 200

MR 300

14条回答
  •  醉梦人生
    2020-11-30 03:36

    Just for a laugh do it the long nasty way....:
    (NOTE: ive not used this, and i would not advise using this.!)

    function pad(str, new_length) {
        ('00000000000000000000000000000000000000000000000000' + str).
        substr((50 + str.toString().length) - new_length, new_length)
    }
    

提交回复
热议问题