473,396 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

I want to validate TextFields for number

If any TextField is empty then message will display.
"Enter the value in TextField". If any alphabate is entered in TextField this is not accepted.
Oct 29 '10 #1
2 1887
Dormilich
8,658 Expert Mod 8TB
what have you tried so far?
Oct 30 '10 #2
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.     function check_num(tmp)
  3.     {
  4.         if((tmp.keyCode>95) && (tmp.keyCode<106))
  5.         {
  6.                     return true;
  7.         }    
  8.         else
  9.         {
  10.                 return false;
  11.         }
  12.  
  13.     }
  14.  
  15.     function check_empty()
  16.     {
  17.             if(document.getElementById("text1").value == "")
  18.             {
  19.                 alert("Enter the value in TextField !");
  20.                 return false;
  21.             }
  22.     }
  23. </script>
  24.  
  25. <form name="form1">
  26.     Enter Value : <Input     type="text" id="text1" name="text1" value="" onkeydown="return check_num(event)" />
  27.     <br />
  28.     <input type="button" name="btn1" value="CLICK ME"  onclick="return check_empty()"/>
  29. </form>
May 17 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: WindAndWaves | last post by:
Hi Gurus Excuse my ignorance.... I am just learning PHP and I am loving it - I am just amazed by what it has to offer - it seems endless. Anyway, I want to ask something very simple. How can...
2
by: Jeff Thies | last post by:
I'm trying to test if a value is a number. I thought I could do this: var test='not_a_number'; var test2='4.00'; num_test=parseFloat(test); if(num_test == 'NaN'){alert('that was not a...
2
by: JAPIO | last post by:
I have a form which is generated by PHP. This form contains one textbox, one textarea and one checkbox all at one row. This row is being repeated multiple times according to the number of results...
9
by: bdog4 | last post by:
I want to validate a number to so that they can only input $2.00, 5.00, 7.00, 50.00 etc... I don't wan them to be able to put cents on the amount. It can either either be 2 or 2.00 Any ideas on...
3
by: Kris | last post by:
I need to create a valid mod10 or luhn number that can be attached to an invoice, I have found several examples showing how to validate a credit card number or validate a number using mod10/luhn. ...
1
by: jhansi | last post by:
hi... I have created a form it's working properly.... but i want to consider phone number and STD code in two different text field for a single lable phone number..... and I have considered...
4
by: AXRabbit | last post by:
Hi, I have created a Textbox for my credit card number entry for my payment webpage. Can anyone help me in telling me the codes of how to make sure 16 digits of the number is entered . Methods such...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.