< input type = "text" name = "password" id = "play user login password" placeholder = "password" class = "layui input no ime" autocomplete = "off" onpaste = "return false" ondregenter = "return false" oncontextmenu = "return false;" style = "ime"- mode:disabled;font-weight : 800">
<input class="password" type="hidden" name="password" id="">
$('#LAY-user-login-password').bind('input', function (e) {
var that = $(this);
var ind = this.selectionStart * 1;
var val = that.val();
function keydel() {
window.onkeydown = function (e) {
if (e.keyCode == 8 && ind == 1 && val.length == 1) {
str = str[0]
} else {
str = val
}
}
}
//Chinese not allowed
for (var i = 0; i < val.length; i++) {
if (val.charCodeAt(i) > 0 && val.charCodeAt(i) < 255) {
$(this).val('')
}
}
if (val.replace(/[\u4e00-\u9fa5]/img, '')) {
$(this).val(val.replace(/[\u4e00-\u9fa5]/img, ''))
}
if (val.length == 0) {
str = ""
}
if (ind == val.lenth) {
str += val[ind - 1]
} else {
if (str.length == val.length) {
str = str
}
else if (str.length > val.length) {
if (val.slice(0, ind) != 'undefined' && val.slice(ind + 1) != 'undefined') {
//If it is removed from the middle (middle letter)
// window.onkeydown = function (e) {
if (keyCode == 8 && ind == 1 && val.length == 1) {
//Delete all at once
str = str[0]
} else if (ind == 1 && val.length == 1) {
//Select all at once and fill in directly without pressing the delete key
str = val
} else if (str.length - val.length != 1) {
//Delete a password
str = str.slice(0, ind) + str.slice(ind + str.length - val.length)
} else {
//Delete only one in the middle
str = str.slice(0, ind) + str.slice(ind + 1)
}
} else if (val.slice(0, ind - 1) == 'undefined' && val.slice(ind - 1) != 'undefined') {
//If so, delete the first letter
str = str.slice(ind - 1)
} else if (val.slice(0, ind - 1) != 'undefined' && val.slice(ind - 1) == 'undefined') {
//If so, delete the last letter
str = str.slice(0, ind - 1)
} else if (val.slice(0, ind - 1) == 'undefined' && val.slice(ind - 1) == 'undefined') {
//If you delete all letters
str = ""
}
} else {
//Plus
if (val.slice(0, ind - 1) != 'undefined' && val.slice(ind - 1) != 'undefined') {
//If it is entered from the middle (middle letter)
if (val.length - str.length != 1) {
//Plus多位密码
str = str.slice(0, ind - 1) + val.slice(ind - (val.length - str.length))
} else {
//If it is entered from the middle (middle letter)
str = str.slice(0, ind - 1) + val[ind - 1] + str.slice(ind - 1);
}
} else if (val.slice(0, ind - 1) == 'undefined' && val.slice(ind - 1) != 'undefined') {
//If it is the first letter, enter (the first letter)
str = val[ind - 1] + str.slice(ind - 1);
} else if (val.slice(0, ind - 1) != 'undefined' && val.slice(ind - 1) == 'undefined') {
//If it is the last input (last letter)
str = str.slice(0, ind - 1) + val[ind - 1];
} else if (val.slice(0, ind - 1) == 'undefined' && val.slice(ind - 1) == 'undefined') {
//If this is the first input (first letter)
str = val[0]
}
}
}
$('.password').val(str)
//The value of input is converted to·
$(this).val($(this).val().replace(/./g, '.'))
})