Javascript: isNaN

i can't get this to work. it was working until i added the if-then statement. can someone help me.


Insert title here








Divides by 100

Number:

Answer:






Comments

  • Hi,

    On form validation

    1. initiate all the controls (set focuses, default values, etc)
    2. test for empty textboxes in the if branch
    3. embed isNaN in the else branch
    4. put further statements in the main branch (basically where you want the execution to take place when all validation is done

    BTW, your script doesn't work because javascript is case-sensitive so a not the same as A.




    Simple Form Validation

    function Calc()
    {
    var myform = document.myform;
    if (myform.A.value == "")
    {
    alert("Please fill in the textbox");

    if (myform.A.value == "")
    {
    myform.A.focus();
    }
    }
    else
    {
    var A = document.myform.A;
    if (isNaN(A.value) == true)
    {
    alert("Please enter a valid number");
    A.value = "";
    A.focus();
    }
    }
    var amount = A.value/100;
    document.myform.B.value=amount;
    }




    Divide by 100:













    : i can't get this to work. it was working until i added the if-then statement. can someone help me.
    :
    :
    : Insert title here
    :
    :
    :
    :
    :
    :
    :
    :
    : Divides by 100
    : Number:
    : Answer:
    :
    :
    :
    :
    :
    :

    [purple]It takes a great deal of living to get a little deal of learning. (John Ruskin)[purple]

Sign In or Register to comment.

Howdy, Stranger!

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

Categories

In this Discussion