str = `{"status": "success","history": [{"tx":"5204759","status":"SUCCESS","date":"04.07.2017","time":"21:53:27","cash":"10,00руб.","orig":"7 000,00руб.","provider":"WebmoneyОАОБанк"ККБ"","opnum":"R14702331","comment":""},{"tx":"5204759","status":"SUCCESS","date":"04.07.2017","time":"21:53:27","cash":"10,00руб.","orig":"7 000,00руб.","provider":"WebmoneyОАОБанк"ККБ"","opnum":"R14702331","comment":""}]}`;
if (str.indexOf('provider') !== -1) {
str = str.replace(/\s/g, '').replace(/(\"provider\":\")(.*?)(\",)/g, function(entry, left, center, right) {
return left + center.replace(/\"/g, '\'') + right;
})
}
// Пример написан в 2014 году, вероятно тогда эта часть кода была нужна
// Сейчас type="number" работает везде, насколько я понимаю.
function (e) {
// Allow: backspace, delete, tab, escape, enter and .
if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||
// Allow: Ctrl+A
(e.keyCode == 65 && e.ctrlKey === true) ||
// Allow: home, end, left, right
(e.keyCode >= 35 && e.keyCode <= 39)) {
// let it happen, don't do anything
return;
}
// Ensure that it is a number and stop the keypress
if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
e.preventDefault();
}
}
if (e.target.value.length > digitsPerBox) {
e.target.value = e.target.value.substr(0,digitsPerBox);
}
if (e.target.value.length == digitsPerBox) {
var t = $( e.target );
if (t.attr("id") == "i4") {
/// SUBMIT HERE
var txt = $("#i1").val() + "-" + $("#i2").val() + "-" + $("#i3").val() + "-" + $("#i4").val();
alert(txt);
} else {
/// AUTO FOCUS NEXT BOX
t.next().focus();
}
}