C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Javascript »

Validate float value while entering using javasript


Posted Date: 10 Oct 2008    Resource Type: Code Snippets    Category: Javascript
Author: Varun BansalMember Level: Gold    
Rating: 1 out of 5Points: 6



This code shows how to validate float value using javascript
on .aspx page


<script language ="javascript" type ="text/javascript">

function check_float(e,field)
{
if (!(((e.keyCode>=48)&&(e.keyCode<=57))||(e.keyCode==46)))
{
alert("Only Digits Are Allowed!");
e.keyCode=0;
}
if (e.keyCode==46)
{
var patt1=new RegExp("\\.");
var ch =patt1.exec(field);
if(ch==".")
{
alert("More then one decimal point not allowed");
e.keyCode=0;
}
}
}
</script>


on code behind (.aspx.cs page) :


TextBox5.Attributes.Add("onkeypress", "check_float(event,document.getElementById('" + TextBox5.ClientID + "').value)");
TextBox6.Attributes.Add("onkeypress", "check_float(event,document.getElementById('" + TextBox6.ClientID + "').value)");




Responses

Author: bansal007    25 Oct 2008Member Level: Bronze   Points : 0
nice


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Validate float value  .  Javascript for float value  .  Check float value while entering  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Performing Hexadecimal Math with JavaScript
Previous Resource: Tests whether two expressions are equal using stricter methods
Return to Discussion Resource Index
Post New Resource
Category: Javascript


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use