/* --------------------- Used in KeyPress Validations --------------------------------
KeyAscii Character
32 Space
40 (
41 )
45 -
44 ,
46 .
48 - 57 0 to 9
13 Enter
*/
function closewindows()
{
if(win && win.open && !win.closed)
win.close();
}
//----------------------------------------------------------------
function CheckNumeric(obj)
{
if (document.getElementById(obj).value != '.')
{
var num = document.getElementById(obj).value;
var testval = Math.ceil(num*10/10);
if (!(testval > -1))
{
document.getElementById(obj).value = "";
return;
}
}
}
/* --------- allows any float values with any number of decimal places ----------- */
function AllowFloat(obj)
{
if (window.event.keyCode == 13)
{
//do nothing
}
else
{
if (!((window.event.keyCode >= 48) && (window.event.keyCode <= 57)))
{
if (!(window.event.keyCode == 46))
{
window.event.keyCode = null
}
else if (window.event.keyCode == 46)
{
if (document.getElementById(obj).value.lastIndexOf(".") > -1)
{
window.event.keyCode = null
}
}
}
}
}
/* --------- allows only 2 decimal places ----------- */
function AllowCurrency(obj)
{
if (window.event.keyCode == 13)
{
//do nothing
}
else
{
if (!((window.event.keyCode >= 48) && (window.event.keyCode <= 57)))
{
if (!(window.event.keyCode == 46))
{
window.event.keyCode = null
}
else if ( window.event.keyCode == 46)
{
if (document.getElementById(obj).value.lastIndexOf(".") > -1)
{
window.event.keyCode = null
}
}
}
else
{
/* --- extra added to restrict to 2 decimal places --- */
if (document.getElementById(obj).value.lastIndexOf(".") > -1)
{
if((document.getElementById(obj).value.length)-(document.getElementById(obj).value.lastIndexOf(".")) > 2)
{
window.event.keyCode = null
}
}
}
}
}
function AllowInt(obj)
{
if (window.event.keyCode == 13)
{
//do nothing
}
else
{
if (!((window.event.keyCode >= 48) && (window.event.keyCode <= 57)))
{
window.event.keyCode = null
}
}
}
function AllowPhoneFax(obj)
{
if (window.event.keyCode == 13)
{
//do nothing
}
else
{
if (!((window.event.keyCode >= 48) && (window.event.keyCode <= 57)))
{
if (!( (window.event.keyCode == 40) || (window.event.keyCode == 41) || (window.event.keyCode == 44) || (window.event.keyCode == 45) || (window.event.keyCode == 32) ))
{
window.event.keyCode = null
}
}
}
}
function AllowZip(obj)
{
if (window.event.keyCode == 13)
{
//do nothing
}
else
{
if (!((window.event.keyCode >= 48) && (window.event.keyCode <= 57)))
{
window.event.keyCode = null
}
}
}
function AllowNonNumeric(obj)
{
if (window.event.keyCode == 13)
{
//do nothing
}
else
{
if (((window.event.keyCode >= 48) && (window.event.keyCode <= 57)))
{
window.event.keyCode = null
}
}
}
function AllowCreditCardNumber(obj)
{
if (window.event.keyCode == 13)
{
//do nothing
}
else
{
if (!((window.event.keyCode >= 48) && (window.event.keyCode <= 57)))
{
if (!( window.event.keyCode == 32 ))
{
window.event.keyCode = null
}
}
}
}
function Trim(TRIM_VALUE){
if(TRIM_VALUE.length < 1){
return"";
}
TRIM_VALUE = RTrim(TRIM_VALUE);
TRIM_VALUE = LTrim(TRIM_VALUE);
if(TRIM_VALUE==""){
return "";
}
else{
return TRIM_VALUE;
}
} //End Function
function RTrim(VALUE)
{
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;
{
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;
while(iTemp > -1)
{
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;
{
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;
} //End While
return strTemp;
return strTemp;
} //End Function
function LTrim(VALUE){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";
var iTemp = 0;
while(iTemp < v_length){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} //End While
return strTemp;
} //End Function
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} //End While
return strTemp;
} //End Function
No comments:
Post a Comment