-1

I want to check if an entered value is 10 or not(and if the value is 10, I want the result to be sent to "send.php"). What am I doing wrong?

<?php  $cod1=rand(0, 10); 
    $cod2=10-$cod1; ?>   
    <form action='send.php'  method='post' onsubmit='f1(this)'>
    Please enter the value of <br> <?php echo $cod1 ?> + <?php echo $cod2 ?> in the following box
    <input type="text" name="xrezultat" id="xrezultat" class="box" size="32"/>

    <input name="Submit1" type="submit" class="butt" value="Trimiteti">      
    <input name="Submit2" type="reset" class="butt" value="Stergeti ">

    </form>


    <Script> 
    function f1(input) 
    {    
    if(document.getElementById("xrezultat").value!=10)   
    aux==false;

     if (aux == true)
    {
       return true;
    }

       else
    {
        alert ( "Please enter the correct value" );
        return false;
                 }


    }
    </script>
Sam
  • 7,252
  • 16
  • 46
  • 65
eu loli
  • 11
  • 1
  • 5

2 Answers2

2

aux==false; checks to see if aux is equal to false, it does not assign to it.

It should read aux=false;.

Snuffleupagus
  • 6,365
  • 3
  • 26
  • 36
0

Try using parseInt.

var numberValue = parseInt(document.getElementById("xrezultat").value, 10);
Daniel A. White
  • 187,200
  • 47
  • 362
  • 445