?
Solved

decimal Validation

Posted on 2005-03-22
2
Medium Priority
?
1,045 Views
Last Modified: 2010-08-05
I just want to make sure that a number is being enter into the form including a decimal. Does the isNaN cover decimals?  

Can I get a validation to check for this?

Thanks

0
Comment
Question by:Docjayman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
mixart earned 2000 total points
ID: 13608380
You could check for a period being present like this...


function checkDec(thisnum){
  thisnum = thisnum.toString();
  var numArray = thisnum.split(".");
  //trace("na:"+numArray);
  if(numArray[1]==undefined){
        trace ("no dec");
  } else {
        trace ("has dec");  
  }
}

numtocheck=100.45;
checkDec(numtocheck);

You could also do a test to make sure there are X number of integers after the decimial with


function checkDec(thisnum){
  thisnum = thisnum.toString();
  var numArray = thisnum.split(".");
  //trace("na:"+numArray);
  if(numArray[1]==undefined){
        trace ("no dec");
  } else {
        trace ("has dec");
        trace ("has "+numArray[1].length +" numbers after decimal")
  }
}

numtocheck=100.45;
checkDec(numtocheck);

0
 

Author Comment

by:Docjayman
ID: 13608506
Outstanding, it worked perfect!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question