问题描述:

I have a probleme with my script. But, this problem one time appear, and one time not, without modification of the code.

My 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>

My 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');

}

}

When i test the form, some time i have problem and some time all is OK. When it's not OK, i have problem on these lines (Chrome Dev Console) :

  • var code = eval(secCode); > in function verificationSecurity()
  • var securityOK = verificationSecurity(document.getElementById('inhuman')); > in function validation()

Sorry for my broken english and thanks in advance for your help.

相关阅读:
Top