In general, the problem is this: There is such a code

String.prototype.isEmail = function() { var str = this.valueOf(), regExp = /^([a-z0-9_-]+\.)*[a-z0-9_-]+@[a-z0-9_-]+(\.[a-z0-9_-]+)*\.[az]{2,6}$/; return regExp.test(this.valueOf()); } 

This method simply checks that the string is Email. The problem is this: When using the method, for example "AZAZA".isEmail() works correctly, but

when using it further, it changes its values ​​from for example false to permanent true. And it does not hibernate back. All this business changes this code, I have no idea how this happens.

 if ("wdwd".isEmail() === false){ //Вот после этого он теперь превращается в true если это не email console.log(isEmail) if (onTemplateEror){ onTemplateEror.call(this, el, 2, obj); } errors.errListFromTemplate.push(el); } 

At the same time, before that, he always output the correct values. What is the problem? Maybe I wrote something wrong? Or is it still a problem inside JS

1 answer 1

there is an ode like elVal.isEmail() elVal is a string coming from the input fields.