473,385 Members | 1,958 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,385 software developers and data experts.

validate numeric entry

i need to validate the form .. fields should not be empty is justified... but the last field i.e var z should be numeric ..please reply fast

Expand|Select|Wrap|Line Numbers
  1. function validateform()
  2.   {
  3.   var x=document.getElementById("nameid").value;
  4.   if(x==''){alert("name should not be empty");return false;}
  5.  var y=document.getElementById("qualificationid").value;
  6.   if(y==''){alert("qualification should not be empty");return false;}
  7.  var z=document.getElementById("rollnumid").value;
  8.   if(z==''){alert("rollnum should not be empty");return false;}
  9. }
Aug 16 '12 #1
3 2460
ariful alam
185 100+
As your question, it is related to JavaScript. So, it's better to post any question in the proper area here.

by the way...

The solution is:

Expand|Select|Wrap|Line Numbers
  1. if(isNaN(z)){
  2.    alert("Please, enter a number");
  3. }
hope works for you. :)
Aug 16 '12 #2
hi ariful... am not getting any alert... please attach ur answer to my code so that i can undersatnd it clearly...thank u for advice
Aug 16 '12 #3
ariful alam
185 100+
Here is a full code:
Expand|Select|Wrap|Line Numbers
  1. <script language='javascript' type='text/javascript'>
  2.  
  3. function validate(){
  4.     if(document.getElementById('name').value==""){
  5.         alert('name field is empty.');
  6.         document.getElementById('name').focus();
  7.     }else if(document.getElementById('qulf').value==""){
  8.         alert('qualification field is empty.');
  9.         document.getElementById('qulf').focus();
  10.     }else if(document.getElementById('roll').value=="" || isNaN(document.getElementById('roll').value)){
  11.         alert('roll number field is empty or not a number.');
  12.         document.getElementById('roll').focus();
  13.     }else{
  14.         alert('validation successful!');
  15.     }
  16. }
  17.  
  18. </script>
  19.  
  20.  
  21. <label>User Name: <input type='text' size='30' id='name' placeholder='please, enter your name.' /></label>
  22. <label>Qualification: <input type='text' size='30' id='qulf' placeholder='please, enter your qualification.' /></label>
  23. <label>Roll Number: <input type='text' size='30' id='roll' placeholder='please, enter your age.' /></label>
  24. <input type='button' id='save' value='validate' onclick='javascript:validate();'/>
Hope works for you. :)
Aug 16 '12 #4

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

Similar topics

5
by: Rob Wahmann | last post by:
Not sure if my first message went through because of the attachment... I'm currently using formchek.js to validate various form fields, however, I cannot figure out how to validate a field with a...
6
by: Peter Afonin | last post by:
Hello, Should be a pretty simple question: I need to validate a string. It must be numeric and contain exactly 12 characters. I know how to do it in code, but I'd like to use a validation...
4
by: Mike Moore | last post by:
We would like to use a validator to valid that only numeric data is allowed in a text box. Is there a way to do this? If so, how?
0
by: Dustan | last post by:
Earlier I asked about limitting what a user can enter in an Entry. I got a few greatly appreciated replies, but I was hoping it would be possible to take a more direct approach, that is, is there a...
7
by: juicy | last post by:
I done a numeric field checking as below, but I found that if I insert float number (10.01), it validate it as non numeric and return false.. What is going wrong? if...
2
by: Earl G via AccessMonster.com | last post by:
I have tried. But now I ask. I cannot get a control to accept a numeric entry (e.g. 0.23) without first entering a zero. I want to allow only two decimal places. But I would like numbers less...
3
by: kang jia | last post by:
hi, now i want to validate numeric value which user filled in in text box, it can have 2 decimal places. what is the regular expression i can use to achieve this? anyone can help? can reply me...
3
by: ebo2006 | last post by:
How can I validate the entry in a form, say cutomer number, is in the masterlist table, else do not accept entry?
4
by: somuchbetta | last post by:
Hiya, Does anyone know any simple JScript code to validate a numeric field and also the length of the data that should be entered into the field. e.g. 12345 - the user can only enter numeric...
5
by: cstansbu | last post by:
This is the item selection piece for a Sharepoint knowledge base. If you type a valid plan code you get info, but if you type garbage you get a 404 file not found. I want to check user input against...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.