[jQuery] Re: Checking if input is a number.

2008-09-16 Thread Andy Matthews
Well, a number by definition can't have spaces in it. So if there ARE spaces, then it's a string, and can be treated as such. Alternately I suppose you could try multiplying the value by 1 and see what you get. andy -Original Message- From: jquery-en@googlegroups.com [mailto:[EMAIL

[jQuery] Re: Checking if input is a number.

2008-09-16 Thread MorningZ
Totally off the top of my head (and therefore totally untested, but it should be good) var EnteredValue = $.trim($(#SearchText).val()); var TestValue = EnteredValue.replace( , ); if (isNaN(TestValue)) { return EnteredValue; // User must have entered a keyword } else { return

[jQuery] Re: Checking if input is a number.

2008-09-16 Thread africanshox
okay..so how can check if the string only contains numbers? im quite new to jquery..would i need to use reg ex? On Sep 16, 3:58 pm, Andy Matthews [EMAIL PROTECTED] wrote: Well, a number by definition can't have spaces in it. So if there ARE spaces, then it's a string, and can be treated as

[jQuery] Re: Checking if input is a number.

2008-09-16 Thread MorningZ
okay..so how can check if the string only contains numbers? Takes out user entered spaces var TestValue = EnteredValue.replace( , ); Checks if the remaining value is numeric isNaN(TestValue) And this method doesn't really need jQuery (nor would i see why it would have to)

[jQuery] Re: Checking if input is a number.

2008-09-16 Thread africanshox
hi thanks for the quick code but this does not seem to evaluate if i enter a number. see code below $(#searchForm input.submitBtn).click(function(e){ var EnteredValue = $.trim($(#keywords).val()); var TestValue = EnteredValue.replace( , );

[jQuery] Re: Checking if input is a number.

2008-09-16 Thread MorningZ
Here is some working code http://paste.pocoo.org/show/85443/ and just to note on your code, you have: alert(is a number) *after* the return TestValue line... that would never ever fire

[jQuery] Re: Checking if input is a number.

2008-09-16 Thread africanshox
thanks so much your a star...i have much to learn... and off i go to do it!!! On Sep 16, 6:41 pm, MorningZ [EMAIL PROTECTED] wrote: Here is some working code http://paste.pocoo.org/show/85443/ and just to note on your code, you have: alert(is a number) *after* the return TestValue

[jQuery] Re: Checking if input is a number.

2008-09-16 Thread RobG
On Sep 17, 12:38 am, africanshox [EMAIL PROTECTED] wrote: i have a serach box that checks for a product code or product keyword. I need to find out how i can check if the  input submitted on this search box is a number, and if it is, remove any white spaces. If by search box you mean an