Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
6
rated 0 times [  12] [ 6]  / answers: 1 / hits: 7566  / 11 Years ago, tue, january 7, 2014, 12:00:00

I am trying to make a function using jquery. And what i am trying to do is that i have a text field and submit button so when i insert numeric value from 1 to 10 it open up a link if the input value is from 11-20 on button click it should open different link.



html



<input type=text Id=number />
<input type=submit id=button />


jquery



 $( document ).ready(function() {
if ( $(#number).val() >= 19200 && num <= 19276 ) {
$( #button ).click(function() {
alert( u enterd the number );
});
}
});


http://jsfiddle.net/2nppc/1/


More From » jquery

 Answers
18

You're going to need something along these lines:



$(document).ready(function(){
$('#button').click(function(){
var number = $('#number').val();
//check if number
if($.isNumeric(number)){
if(number >= 1 && number <= 10){
//1-10 action
}elseif(number >= 11 && number <= 20){
//11-20 action
}
}else{
//Not a number
}
});
});


EDIT: sorry mixed up the format for checking numeric, sorted now :)


[#48935] Monday, January 6, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alfonsok

Total Points: 386
Total Questions: 101
Total Answers: 90

Location: Puerto Rico
Member since Sun, Jun 27, 2021
3 Years ago
;