麻烦检查是否有值且可见

时间:2014-06-05 13:45:26

标签: javascript html css coldfusion

在数组中列出了几个变量。

<cfset inputs = ["from","subject","custnumber","amount","password"] />

必须测试每个变量以查看两个事物是否为真,它是否可见,并且字段已满或传递错误。

function formcheck() {
thiserror = 0;
<cfloop array="#inputs#" index="thisinput"> 
    if (document.getElementById('#thisinput#' + 'real').value == '') AND $('##' +'#thisinput#' + 'container').css('display') != 'none') {
        thiserror = 1;          
        $("###thisinput#errortip").fadeIn(300);
        }

</cfloop>

不断收到“缺失;声明前错误”

完整代码:

<cfoutput>
function formcheck() {
thiserror = 0;
<cfloop array="#inputs#" index="thisinput"> 
    if (document.getElementById('#thisinput#' + 'real').value == '' AND $('##' +'#thisinput#' + 'container').css('display') != 'none') {
        thiserror = 1;          
        $("###thisinput#errortip").fadeIn(300);
        }

</cfloop>
    if (thiserror == 0) {
        load('#targeturl#','#targetdiv#',
            <cfloop array="#inputs#" index="thisinput">
            '&#thisinput#=' + document.getElementById('#thisinput#' + 'real').value +
            </cfloop>
            ''
            )


    }
}

1 个答案:

答案 0 :(得分:0)

我不确定这是否是您Javascript中唯一的错误 - 但我确信&#39; AND&#39;不是Javascript运算符。据我所知,&#39; AND&#39;仅适用于ColdFusion本身。 将其替换为等效的Javascript&#39;&amp;&amp;&#39;你的代码应该可以工作。

此外,你真的丢失了分号:你的load() - 函数缺乏分号。

相关问题