为什么我遇到禁止错误,我的代码是-
$('#ContentPlaceHolder1_txtAccount1').keyup(function () {
console.log("key press working");
var foo = $(this).val(); // Get Current Text Box Value
var hyphenPos=[3,8,11,14,20]//12-1234-12-12-12345-123 mapping hyphen positions
if($.inArray(foo.length,hyphenPos)>-1) // Check if we need to add hyphen
{
var beforeHyphen=foo.substr(0,foo.length-1); // substring except last character
var lastcharacter=foo.substr(foo.length-1,1); // last character
var finalString=beforeHyphen+'-'+lastcharacter; // final result
$(this).val(finalString); // show
}