tri_inn Level: Regular User Registered: 26-08-2002 Posts: 395
|
Need crossbrowser javascript for numeric textbox ?
i have developed a numeric textbox web server control. it generates javascript when form load but
my javascript only works in IE browser. so please give me the same javascript which will work in
IE & Netscape.
here i am giving my javascript which is generated by my control
<script language=JavaScript>
function DoCheck_NumBox1(event)
{
var negative;
var Decimal = 46;
var DeciPlaces =2;
var AllowNegative =true;
var myString = new String(event.srcElement.value);
var pntPos = myString.indexOf(String.fromCharCode(Decimal));
var keyChar = window.event.keyCode;
if (AllowNegative==true)
{negative=myString.indexOf('-');
if (negative = -1)
{
if (myString.length <= 0)
return true;
}
else
{
return false;
}
}
if (keyChar == Decimal)
{
if (pntPos != -1)
{
return false;
}
else
{
if(DeciPlaces <=0)
{
return false;
}
else
{
return true;
}
}
}
if ((keyChar < 48) || (keyChar > 57))
{
return false;
}
else
{
if (pntPos != -1)
{
if ((myString.length - (pntPos + 1)) >= DeciPlaces)
return false;
}
else
{
return true;
}
}
}
</script>
|