0

I want to check the number of user input. If it negative number it will disable the sumbit botton.
my code is run but let say i enter three -1 and if i change of it to positive the sumbit botton is enable. I want make sure if all the number positive before enable sumbit botton

here is code

if (x < 0 )
        {   
            if (document.getElementById('AX') && document.getElementById('XR') && document.getElementById('ZZ') < 0)
            {
                document.getElementById('cmdSubmit').disabled = true;
                alert('There is a problem! Cannot be negative number.');

                return false;
            }
            // If the script gets this far through all of your fields   
            // without problems, it's ok and you can submit the form
            else 
            {
                document.getElementById('cmdSubmit').disabled = false;

                return true;
            }
        }
2
Contributors
1
Reply
20
Views
2 Years
Discussion Span
Last Post by wesley.cheng
0

document.getElementById('ZZ') is the element, not input value.

<input type="text" id="ZZ" value="test" />


document.getElementById('ZZ') is '<input type="text" id="ZZ" value="" />'

document.getElementById('ZZ').value is 'test'
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.