The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> javascript function for numeric validation
prasanna
post Oct 31 2007, 04:54 AM
Post #1





Group: Members
Posts: 2
Joined: 17-October 07
Member No.: 4,079



Hi,
I want to validate a form field for numeric value. I have written the following function..

function validateTradeSize() {
if (document.executeForm.tradeSize.value==null || document.executeForm.tradeSize.value.length==0 || isNaN(document.executeForm.tradeSize.value) || Number(document.executeForm.tradeSize.value) > 9999999) {
alert('Trade Size must be a number less than 10000000.');
document.executeForm.tradeSize.value = "";
document.executeForm.tradeSize.focus();
return false;
}
}

This function fails if one or more spaces are entered into tradeSize. Is there any standard trim() function available in javascript?

Thanks,
Prasanna
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Nov 1 2007, 04:45 PM
Post #2


.
********

Group: WDG Moderators
Posts: 7,919
Joined: 10-August 06
Member No.: 7



Here are some ideas: http://www.irt.org/script/1310.htm
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 20th October 2018 - 03:05 PM