Reputation: 12754
I have two textboxes that will be used to search for the amount of Weapon, therefore Weapon Range Amount.
Either of the two is blank is ok, but the 2nd textbox shouldnt be greater than the value of the 1st textbox.
I'm torn between the tests made by keyup and change
the code's behavior is
1)Input 11(higher number) on 1st textbox 2)hit Tab 3)Input 2(lower number) on the 2nd 4)alert fires up
11>2 right? but the it still got inside the
if (weaponLess < weaponMore)
fyi
var weaponLess=$("#weaponAmtSuuji1").val();
var weaponMore=$("#weaponAmtSuuji2").val();
seems it compared the value of the 2nd textbox before it got an input
I have a hidden textbox which I showed on the code, and it should capture both of the input and should check if each of the two has an input or none
then join the inputs in a pattern like "WeaponAmount
< "+txtBox1+" AND WeaponAmount
> "+txtBox2"
html
Search Weapon Amount Range
<br>
<label>Weapon Amount Less</label> 
<input type="text" id="weaponAmtSuuji1"/> <span id="weaponAmtErrmsg1"></span> 
<br>
<label>Weapon Amount More</label> 
<input type="text" id="weaponAmtSuuji2"/> <span id="weaponAmtErrmsg2"></span>
<br>
<input type="text" name="WeaponAmount" id="weaponAmtFld">
jquery
http://jsfiddle.net/yuuto/75V8S/
you may noticed I put
/*$('#weaponAmtFld').val(function(index, val) {
if (val.indexOf("AND")>0)...
on comment, if removed it, the script doesnt seem to perform even the
if (weaponLess < weaponMore) {
parts
really need help
Upvotes: 1
Views: 588
Reputation: 1122
String compare rules :) (see my comment)
if (parseInt(weaponLess) < parseInt(weaponMore)) {
Upvotes: 1