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

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.