jsf / icefaces中的javascript [英] javascript in jsf/icefaces
本文介绍了jsf / icefaces中的javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有jspx扩展名的文件我写javascript就像
I have file with jspx extension i write javascript like
function isNumber(inputId){
var value = document.getElementById('mainForm:'+ inputId).value;
var s = value.length;
while(s >= 0){
var c = value.charAt(s);
if(c > "9"){
alert("Value must be digit");
document.getElementById('mainForm:'+ inputId).value = "";
document.getElementById('mainForm:'+ inputId).focus();
return false;
}
s --;
}
return true;
}
工作完美,但当我检查条件是否如果(c>9 || c<0)它会给出错误,如
that work perfect but when i check if condition like if(c > "9" || c < "0") it will gives error like
com.sun.facelets.FaceletException: Error Parsing /WEB-INF/includes/templates/cc-classic-template.jspx: Error Traced[line: 386] The content of elements must consist of well-formed character data or markup.
经过长时间的观察,我发现<(小于)符号会产生问题。
JSF不支持<签署?
After long observation i found that <(less than) sign will create problem. Is JSF not support < sign ?
推荐答案
除了转义和CDATA答案:
Besides the escaping and CDATA answers:
如果你想检查一个值是否是一个数字,有一个javascript内置函数: isNaN
If you want to check if a value is a number, there is a javascript built-in function for that: isNaN
这是一个例子:
if (isNaN(document.getElementById('mainForm:'+ inputId).value))
{
alert("Please enter digits");
document.getElementById(obj).focus();
document.getElementById(obj).select();
return false;
}
这篇关于jsf / icefaces中的javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文