XSL文件我有以下的xsl:JavaScript验证在输入字段
<xsl:template match="attribute[controlType='TextBox']">
<input style="width:180pt" type="input" value="">
<xsl:attribute name="id">fldCsXML_<xsl:value-of select="name"/></xsl:attribute>
<xsl:attribute name="name">fldCsXML_<xsl:value-of select="name"/></xsl:attribute>
<xsl:attribute name="value"><xsl:value-of select="data"/></xsl:attribute>
</input>
</xsl:template>
我想要做的JavaScript验证的价值的一部分,不允许符号。只是为了允许数字或字母。
也许有类似的jQuery:
try bellow script this will not allow special charter # $ %^& * ()
function validate() {
var element = document.getElementById('input-field');
element.value = element.value.replace(/[^[email protected]]+/, '');
};
<input type="text" id="input-field" onkeyup="validate();"/>
中以最简单的方式改变了xsl以上,增加的jQuery/JavaScript验证任何帮助表示赞赏
尝试''并在JS正则表达式中添加锚'/^[a-z _] $/i.test(keyChar)' – Tushar
@Tushar调查此问题。请注意,它需要为IE8和一些老的浏览器,如Mozilla 4 – topcat3