日期:2014-05-17  浏览次数:20577 次

动态添加的表单元素要怎么验证文本框的值??拜托了各位
动态添加的表单元素要怎么验证文本框的值
下面是动态生成的两个文本框
我要怎么验证文本输入的值,
var voteoptions = document.getElementById("voteoptions");
var _p = document.createElement("p");
var _input = document.createElement("input");//第一个文本框
_input.type = "text";
_input.className = "text easyui-validatebox validatebox-text validatebox-invalid";
_input.setAttribute("name", "tour.tourPriceMember");

var _input1 = document.createElement("input");//第二个文本框
_input1.type = "text";
_input1.className = "text easyui-validatebox validatebox-text validatebox-invalid";

_input1.setAttribute("name", "tour.tourPriceMember");
_p.appendChild(document.createTextNode("报价名称:"));
_p.appendChild(_input);
_p.appendChild(document.createTextNode("价格:"));
_p.appendChild(_input1);
我要验证价格文本框输入的是价格类型的数据,要怎么验证,拜托了各位

------解决方案--------------------
javascript写一个validate方法,然后用onblur来调用
JScript code

_input.onblur="validate(this)";