If x equals something then do not run function

EsterG14

New Member
I am new to JavaScript and HTML. I have this line of code in my JavaScript file:\[code\]if (q1 == '' && q2 == '' && q3 == '' && q4 == '' && q5 == '') {alert("You must enter a question");thisform.q1.focus();return false;}\[/code\]Basically, q1 q2 and so on are textboxes and if they are left blank an alert pops up and says You must enter a question. In my HTML file I have this line of code\[code\]<script type="text/javascript">function add() {var num = document.getElementById("n1").value;if(num == '') num = 0;document.getElementById("n1").value = http://stackoverflow.com/questions/15576787/parseInt(num ,10) + 1; var num = document.getElementById("n2").value;if(num == '') num = 0;document.getElementById("n2").value = http://stackoverflow.com/questions/15576787/parseInt(num ,10) + 1;var num = document.getElementById("n3").value;if(num == '') num = 0;document.getElementById("n3").value = http://stackoverflow.com/questions/15576787/parseInt(num ,10) + 1;var num = document.getElementById("n4").value;if(num == '') num = 0;document.getElementById("n4").value = http://stackoverflow.com/questions/15576787/parseInt(num ,10) + 1;var num = document.getElementById("n5").value;if(num == '') num = 0;document.getElementById("n5").value = http://stackoverflow.com/questions/15576787/parseInt(num ,10) + 1;}</script>\[/code\]Then Later:\[code\]<INPUT onclick="addQ(myForm);add();" value="http://stackoverflow.com/questions/15576787/Add Question" id="question add" type=button>\[/code\]Is there any way that I can make the add() function not execute if my alert pops up?
 
Back
Top