var value1= +$("input#amount").val(), value2= +$("input#amount").val(); if(value1 > value2){ value1 = value2; ....