Can you show me how to validate height and width are greater than 0 Game Design and Programming
You're browsing the GameFAQs Message Boards as a guest. Sign Up for free (or Log In if you already have an account) to be able to post messages, change how messages are displayed, and view media in posts.
<form name="Theform" id="frmcontact" method="get"> Enter the width and height of your triangle to calculate the area<br> Width (b):<input type="text" id="width" name="txtwidth"> Height (h):<input type="text" id="height" name="txtheight"> <input type="button" value="Calculate area" id="calc" onclick="area()"> </form>
You're close! You'll want to doublecheck which logical operator you need to use in your if statements, in order for execution to go inside them.
Currently, you're using &&, the "AND" logical operator, which takes the form of A && B. For that logical operator to evaluate to true, both A and B must be true. So in your code, if A is less than 0, but B is not less than 0, the if statement's body won't execute. Similarly, if B is less than 0, but A is not less that 0, the if statement's body won't execute. Look at the logical operators in that page, and see which one suits your needs instead of && :)
|__ I make indie games! Get them for free at http://nesis.itch.io __| |__ Let me know what you think! __________________________|