0
我有包含百分比值(如2.5%等)的文本框列表。有一个验证用于检查用户是否输入了任何特殊字符。如果是这样,警告框应弹出适当的警报消息。但是当我输入任何无效数据时,警报框不会关闭。从任务管理器。我必须关闭IE。任何帮助将不胜感激。警报框未关闭
JSP代码 -
<html:text property="manualValPctNum" name="manualValueInputPO" styleId="manualValPctNum" size="25" indexed="true" maxlength="25" onblur="javascript:formatValues('moduleForm', '${row.index}')" onfocus="javascript:removeValueFormat('moduleForm', '${row.index}')"/>
的JavaScript代码 -
function formatValues(form, rowIndex){
var beginElem = "manualValueInputPO[";
var endElement = "]";
var attributeName =beginElem+ rowIndex+endElement;
formatPercentAmount(form,attributeName);
value = "";
}
function formatPercentAmount(form, attributeName){
var manualValueAmt = document.getElementsByName(attributeName+".manualValueAmt")[0];
var manualValPctNum = document.getElementsByName(attributeName+".manualValPctNum")[0];
var decimalForTabOut = document.getElementsByName(attributeName+".decimalForTabOut")[0];
if(manualValPctNum.value != undefined && manualValPctNum.valu`enter code here`e != ''){
if(isNaN(manualValPctNum.value)){
alert("Enter numeric value only without entering any '$', comma, '()', '%', or alphabets. Use '-' when entering a negative value.");
value = "true";
manualValPctNum.focus();
manualValPctNumFlag = true;
modifiedString = "";
replacedChar = "";
}else{
var amt = manualValPctNum.value;
amt = amt.toString();
decimalForTabOut.value = amt.indexOf('.');
var indexPos = amt.indexOf('.');
if(indexPos == -1){
modifiedString = amt.concat("00");
nonDecimalPoint = true;
}else{
var pctNumBeforeDecimal = amt.substring(0,indexPos);
var pctNumAfterDecimal = amt.substring(indexPos + 1,amt.length);
var modifiedIndexPos = indexPos + 2;
var pctNum = pctNumBeforeDecimal.concat(pctNumAfterDecimal);
for(var i = 0; i<pctNum.length; i++){
if(i == modifiedIndexPos){
replacedChar = pctNum[i];
modifiedString = modifiedString.concat('.');
modifiedString = modifiedString.concat(replacedChar);
}else{
if(modifiedString == undefined || modifiedString == ""){
modifiedString = pctNum[i];
}else{
modifiedString = modifiedString.concat(pctNum[i])
}
}
}
}
manualValueAmt.value = modifiedString+"%";
manualValPctNum.value = modifiedString+"%";
modifiedString = "";
replacedChar = "";
manualValPctNumFlag = false;
}
}
}
这是IE浏览器唯一的问题吗? –
@Harsha ...我只能在IE中运行此代码,而不能在其他浏览器中运行。 – OnlyPatil
@ harsha ..我在Chrome中测试它,它工作正常。警报框正在关闭。 – OnlyPatil