VM9878:1未捕获的SyntaxError:意外的标识符

时间:2016-05-14 13:09:35

标签: javascript

我的脚本存在问题。但是,这个问题有一次出现,有一次没有修改代码。

我的HTML:

<div class="input-group">
    <span class="input-group-btn">
        <button class="btn btn-default" type="button" onclick="security();"><i class="glyphicon glyphicon-refresh"></i></button>
    </span>
    <input id="inhuman" type="text" class="form-control" name="inputhuman" onblur="verificationSecurity();">
    <span id="humanerror" class="w39 input-group-addon"></span>
</div>

<div class="col-md-2">
    <button id="send-mail" class="btn btn-primary pull-right w100" onclick="validation();">
        <span class="glyphicon glyphicon-send"></span>
    </button>
</div>

我的Javascript:

function securityCode() {

    [... MAKING THE SECURITY CODE ...]

    document.getElementById('inhuman').placeholder = secCode;
}

function verificationSecurity() {
    var secCode = document.getElementById('inhuman').placeholder;
    var secResult = document.getElementById('inhuman').value;
    var code = eval(secCode);

    if(code == secResult) {
        document.getElementById('humanerror').className = 'input-group-addon form-ok';
        document.getElementById('humanerror').innerHTML = '<i class="fa fa-check" aria-hidden="true"></i>';
        return true;
    } else {
        document.getElementById('humanerror').className = 'input-group-addon form-error';
        document.getElementById('humanerror').innerHTML = '<i class="fa fa-exclamation-triangle" aria-hidden="true"></i>';
        return false;
    }
}

function validation() {
    [... SOME OTHERS TESTS OK ...]
    var securityOK = verificationSecurity(document.getElementById('inhuman'));

    if(nameOK && emailOK && objectOK && messageOK && securityOK) {
        alert('ONLY FOR TESTS - OK');
    } else {
        alert('ONLY FOR TESTS - NOT OK');
    }
}

当我测试表单时,有时候我有问题,有些时候一切都还可以。如果不行,我在这些方面遇到问题(Chrome Dev Console):

  • var code = eval(secCode); &GT;在函数verificationSecurity()
  • var securityOK = verificationSecurity(document.getElementById('inhuman')); &GT;在函数验证()

对不起我的英语,请提前感谢你的帮助。

0 个答案:

没有答案