H I O X INDIA
FREE Javascript
 HOME  ||  Scripts  ||  Purchase  ||  Tutorials  ||  Images  ||  Tools  ||  Directories 
  :-)  Send Page   :-)   Feedback   :-)   Register   :-)   Links   :-)   Support   :-)   Bookmarks :-)  
 Forums   Hosting   Internet Stats   Easy Calculation   FUN Games 

Java Script Source
List All
Date & Time
Calendar
Stop Watch script
Slide Show
Image Effect
Mouse Effects
Color Picker Tool
Dynamic Color
Random Generator
Select All
Form Validation
Textbox Counter
Dynamic Form select
Bookmark
Window / User Info
Pagination
Security / Authenticate
Status Bar
Title Bar
Cursor Position
Country List
Calculators
Delete Repeated Values
Alphanumeric
Free Games





Integers with Two decimal places Script


About
This javascript will help you to accept only integers with two decimal places.


Features
a) This javascript is used to accept only integers with two decimal places.
b) Just copy the code into your page and use it.


Preview

Enter a number with up to two decimal places




Code
Javascript
<!--        Script by hscripts.com          -->
<!--        copyright of HIOX INDIA         -->
<!-- more scripts @ http://www.hscripts.com -->

<script language=javascript>
function checkDecimals(fieldName, fieldValue)
{
  decallowed = 2;  
  if (isNaN(fieldValue) || fieldValue == "")
  {
    alert("Not a valid number.try again.");
    fieldName.select();
    fieldName.focus();
  }    
  else
  {
   if (fieldValue.indexOf('.') == -1) fieldValue += ".";
   dectext = fieldValue.substring(fieldValue.indexOf('.')+1, fieldValue.length);

   if (dectext.length > decallowed)
   {  
      alert ("Enter a number with up to " + decallowed + "decimal places. try again.");
      fieldName.select();
      fieldName.focus();
   }
   else
   {
     alert ("Number validated successfully.");
   }
  }
}

</script> 

<!-- Script by hscripts.com -->


HTML Code
<!-- Script by hscripts.com -->

<form name="frm">
Enter a number with up to 2 decimal places:<br>
<input type=text name="txt">
<input type=button name=ok value="Ok" onclick="checkDecimals(this.form.txt, this.form.txt.value)"><br><br>
<div align=right>&copy;<a href="http://www.hscripts.com" style="color: #3D366F;text-decoration:none;cursor:pointer;font-size:13px;">hscripts.com</a></div>
</form>

<!-- Script by hscripts.com -->

Release Date - 07-04-2008

Get free version without ©copyright link for just 5



Usage

a) This java script is used to accept only integers with two decimal places in a textbox.
b) The function checkdecimals() is called to accept integers with two decimal places.
c) Copy the code into your page and use it.





License
- This javascript (misspelled as java script)/HTML code is given under GPL License
- i.e. Free use for those who use it as it is.
- Free, if your modification does not remove our copyright information and links.
- Detailed License information can be found here
- You can purchase the script if your requirements does not meet GPL License terms.


privacy policy     license     sitemap
© 2004-2005 HIOX INDIA - hioxindia.com

Others