This will be the first time on SO I don't preface my question with, "I'm new to programming" (whoops). I'll get right into it:
Here's my HTML code:
<div class="hide" id="hide2">
<div class="inputselect">
<p>
<label>What is your budget?</label>
</p>
<p>
Minimum: $<input type="text" id="minBud" name='minBud'><br />
Maximum: $<input type="text" id="maxBud" name='maxBud'><br />
<br />
</p>
<button type="button" class="next" id="next3">Next</button>
<button type="button" class="prev" id="prev2">Previous</button>
</div>
</div>
Here's the jQuery/javascript code snippet I'm struggling with:
$("#next3").click(function(){
if (typeof $("#minBud").val() === "number" && typeof $("#maxBud").val() === "number") {
gunsPrice();
$("#hide3").slideDown("fast");
$("#hide2").slideUp("fast");
} else {
alert("Please only enter NUMBERS into the budget fields");
}
});
What I'd like to see happen is: if the entries the the minBud
and maxBud
fields are numbers, run gunsPrice()
and present the next question (HTML form).
I've tried altering the syntax several different ways, but no matter how I do it, numbers continue to trigger the alert
.
Note: I can get the typeof
operator to function correctly within gunsPrice()
(using variables gathered with getElementById
, but that doesn't do me any good within this application; it always moves to the next question (due to the way I've set up the jQuery code).
Thanks!