0
我想在输入元素本身中显示错误消息,而不是单独显示错误消息。我将如何捕获消息需要显示的元素?在javascript中捕获元素
本的代码:
function checkForm(form) {
if (yname.getValue() == "" || yname.getValue() == "Your Name" || name.getValue() == "" || name.getValue() == "Name of the Book" || url.getValue() == "" || url.getValue() == "URL of the Book"){
[id-of-the-element].setTextValue("Field cannot be empty!");
return false;
}
这是,如果我理解正确的你 - 你需要知道哪些字段为空 – 2010-07-22 15:10:28
我想有没有别的办法? – input 2010-07-22 15:28:02
当然它可以用某种方式重构,例如(yname.getValue()==“”|| yname.getValue()==“Your Name”)可以移入单独的函数中。 但是没有一个标准函数可以调用,它会给你什么字段为空。但是,可能有,也可能在某个地方,函数获取表单的空字段。但在你的例子中,你的字段有一些默认值,它们也被视为一个空值。 – 2010-07-22 15:44:48