Plz help me - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Plz help me

neenasasidharaneenasasidhara Posts: 2Member
else if(!(IsNumeric(document.myform.Phone.value)))
{
alert("Please enter 'Number'");
document.myform.Phone.focus();
return false;
}

using these codes i have to satisfy these following conditions
1) the entered value must be an integer
2)if the value entered is a string ,an error message should be thrown in a seperate dialogue box(using javascript)

Plz mates help me

Comments

  • zibadianzibadian Posts: 6,349Member
    : else if(!(IsNumeric(document.myform.Phone.value)))
    : {
    : alert("Please enter 'Number'");
    : document.myform.Phone.focus();
    : return false;
    : }
    :
    : using these codes i have to satisfy these following conditions
    : 1) the entered value must be an integer
    : 2)if the value entered is a string ,an error message should be
    : thrown in a seperate dialogue box(using javascript)
    :
    : Plz mates help me
    :
    Here's a simple code to check if a string is an integer:
    [code]
    try {
    phoneNumber = Integer.parseInt(Phone.value);
    catch (NumberFormatException e) {
    alert("Not a number");
    }
    [/code]
    phoneNumber now holds the integer repesentation of the number entered.
    For more info see: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Integer.html#parseInt(java.lang.String)
Sign In or Register to comment.