Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Only numeric data in NETSCAPE6.0

Status
Not open for further replies.

kedarhukeri

Programmer
Dec 30, 2002
4
0
0
DE
Dear Friends,
I have following script which works for IE5.0 but it's not working in Netscape5.0onwards.
Can anyone help me /suggest alternate approch?
*************************
<SCRIPT LANGUAGE=&quot;Javascript&quot;>
function numberCheck()
{
if (event.keyCode < 48 || event.keyCode > 57)
{
event.returnValue = false;
alert('NUMBERS ONLY');
}
else
{
event.returnValue = true;
}
}
</SCRIPT>

<BODY>
<INPUT TYPE=&quot;TEXT&quot; onKeyPress=&quot;numberCheck();&quot;>
</BODY>
 
try this:
Code:
<SCRIPT LANGUAGE=&quot;Javascript&quot;>
function numberCheck()
{
    if (event.which < 48 || event.which > 57)
        {
            event.returnValue = false;
            alert('NUMBERS ONLY');
        }
    else
        {
            event.returnValue = true;
        }
}
</SCRIPT>

<BODY>
<INPUT TYPE=&quot;TEXT&quot; onKeyPress=&quot;numberCheck();&quot;>
</BODY>

hope it helps &quot;Those who dare to fail miserably can achieve greatly.&quot; - Robert F. Kennedy
So true..
 
Hello,Dookie2k2
thanks for ur reply.
I am sorry but it didnt worked with netscape and IE also.
What do you mean by this:
if (event.which < 48 || event.which > 57)
event.which ? is this a name of any property.
Can anyone guide me please to make the number validation workable for Netscape 5.0 And IE 5.0?

thanks
Kedar

 
event.which should return the keycode in nestcape, but it obviously wont work in IE. i dont have netscape so I cant really test this but I dont see why it wouldnt work.
Code:
<SCRIPT LANGUAGE=&quot;Javascript&quot;>
function numberCheck(val)
{
    if (isNaN(val))
        {
            event.returnValue = false;
            alert('NUMBERS ONLY');
        }
    else
        {
            event.returnValue = true;
        }
}
</SCRIPT>

<BODY>
<INPUT TYPE=&quot;TEXT&quot; onKeyPress=&quot;numberCheck(this.value);&quot;>
</BODY>

try that, hope it works. &quot;Those who dare to fail miserably can achieve greatly.&quot; - Robert F. Kennedy
So true..
 
Dookie2k2 ,
sorry friends, Its not working with Netscape.
Is it that tough?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top