gpt4 book ai didi

javascript - Microsoft JScript 运行时错误 : Cannot assign to a function result?

转载 作者:太空宇宙 更新时间:2023-11-03 15:35:45 25 4
gpt4 key购买 nike

if (Trim(document.getElementById("txtAffiliateName").value)=""){
alert("Please enter 'Affiliate Name'.");
document.getElementById("txtAffiliateName").focus();
return false;
}

当我在 ASP.NET 中使用此代码时,它会发出警报:

Microsoft JScript runtime error: Cannot assign to a function result

使用 continue,ignore,break 选项,当我点击 continue 时,它会进入页面加载并正常工作,当我点击 break 时> 它停止执行。

if (document.getElementById("txtAffiliateName").value="") {
alert("Please enter 'Affiliate Name'.");
document.getElementById("txtAffiliateName").focus();
return false;
}

当我删除 Trim 时,不会显示警报错误消息。但是 TextBox 值在按钮单击时将为空。解决方案是什么?

最佳答案

你应该使用 Comparison Operator ==

改变这个:

if (Trim(document.getElementById("txtAffiliateName").value) = "")

对此:

if (Trim(document.getElementById("txtAffiliateName").value) == "")

关于javascript - Microsoft JScript 运行时错误 : Cannot assign to a function result?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31934060/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com