[英]Alert Box is not closing
我有一個文本框列表,其中包含諸如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;
}
}
}
請使用onClick事件更改onFocus事件,使用onFocus更改,只要您在瀏覽器上單擊可用空間,它將調用該函數
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.