相关疑难解决方法(0)

使用Javascript函数设置输入值

我目前正在使用YUI小工具.我也有一个Javascript函数来验证来自divYUI为我绘制的输出:

Event.on("addGadgetUrl", "click", function(){
    var url = Dom.get("gadget_url").value;  /* line x ------>*/
    if (url == "") {
        error.innerHTML = "<p> error" /></p>";
    } else {
        /* line y ---> */ 
        /*  I need to add some code in here to set the value of "gadget_url" by "" */
    }
}, null, true);
Run Code Online (Sandbox Code Playgroud)

这是我的div:

<div>
<p>URL</p>
<input type="text" name="gadget_url" id="gadget_url" style="width: 350px;" class="input"/>
<input type="button" id="addGadgetUrl" value="add gadget"/>
<br>
<span id="error"></span>
</div>
Run Code Online (Sandbox Code Playgroud)

正如你可以看到我的问题是,我怎么能设置的值gadget_url是""?

javascript validation yui input

193
推荐指数
3
解决办法
62万
查看次数

标签 统计

input ×1

javascript ×1

validation ×1

yui ×1