Javascript:if语句上的奇怪的非法字符错误 [英] Javascript: Weird illegal character error on a if statement

查看:142
本文介绍了Javascript:if语句上的奇怪的非法字符错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从昨天以来,我一直在努力处理一个奇怪的语法错误:FF调试器在这个特定的行继续说SyntaxError:illegal character:

I've been struggling with a strange syntax error since yesterday: The FF debugger keeps saying "SyntaxError: illegal character" at this specific line :

function newTimePeriod(ID, param, paramID, unit)
{
    updateSession();
    //check if date
    //(I got this regex from another post)
    var re = new RegExp("^\\d{4,4}(-\\d{1,2}){1,2}( \\d{1,2}(:\\d{1,2}){1,2})?$");

    var dateFrom = document.getElementById("chart_date_min_" + ID).value;
    var dateTo = document.getElementById("chart_date_max_" + ID).value;
    var fromCorrect = re.test(dateFrom);  
    var toCorrect = re.test(dateFrom);  
    /**/if (fromCorrect && toCorrect)​{/**/   //return illegal character
    LoadGraph(ID, param, paramID, unit, dateFrom, dateTo);
    }
}

我试图将这个脚本包含到主php页面,或分开;它不改变一件事。使用的字符集是UTF-8,fromCorrect和toCorrect正确返回布尔值(正则表达式正在工作)

I tried to include this script into the main php page, or separate it; it doesn't change a thing. Charset used is UTF-8, and fromCorrect and toCorrect returns booleans correctly (the regex is working)

当我删除if语句时脚本正在加载...
Notepad ++不显示任何隐藏任何特殊字符。

When I remove the if statement the script is loading... Notepad++ doesn't show any special characters hiding anywhere.

任何想法?

推荐答案

我已将您的代码复制到小提示中 - 您似乎有一个 zero-width空格

I have copied your code into a fiddle - seems you have a zero-width space between the braces:

if (fromCorrect && toCorrect)​{
                             ^

这篇关于Javascript:if语句上的奇怪的非法字符错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆