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

Java script validation for numeric and text field

Hi.,

Please help me for java script validation for text and numeric field.
May 23 '07 #1
4 21496
DeMan
1,806 1GB
Hi Thiyagusathya ,
Welcome to the scripts. I am moving your post to the JavaScript forum where you will get a better response from javascript experts. In future you can find this by selecting the forums option on the blu bar at the top of the screen.
I hope you find the answers you require
May 23 '07 #2
acoder
16,027 Expert Mod 8TB
Hi.,

Please help me for java script validation for text and numeric field.
Have a look at the validation links in the Offsite Links thread (sticky).
May 23 '07 #3
Hi.,

Please help me for java script validation for text and numeric field.

HI
you can use the following function for the fields you want to validate

Number Validation:

Expand|Select|Wrap|Line Numbers
  1. function numericValidate(string) {
  2.     var intCharCode;
  3.     for (var i = 0; i < string.length; i++) {
  4.       intCharCode = string.charCodeAt(i);        
  5.         if (!((intCharCode >= 48 && intCharCode <= 57))) 
  6.         return false; (or)
  7.                     alert("it is not a number");
  8.     }
  9. }

String Validation:(it wont allow spaces between or at any place in the string)

Expand|Select|Wrap|Line Numbers
  1. function strValidate(string)
  2. {
  3.     var testName =/^([a-z]|[A-Z]| )*$/;
  4.     if(!testName.test(string))
  5.     {
  6.         return false; (or) alert("Enter only string values");
  7.     }
  8. }
May 25 '07 #4
@Thiyagusathya
Basicallly When we trying to validate a form some time we need numeric validation for textbox.

We can validate textbox by onkeypress event of the control By checking whether the keycode of the key pressed as the user types falls within the range of the number keys 48-57(i.e 0-9 and '.') ,if not belong to that range it will return false then it will disable the keypress action
Jun 16 '10 #5

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

Similar topics

21
by: Stefan Richter | last post by:
Hi, after coding for days on stupid form validations - Like: strings (min / max length), numbers(min / max value), money(min / max value), postcodes(min / max value), telefon numbers, email...
5
by: Yellowbird | last post by:
Hi all, I'm new to JavaScript, but am pretty sure what I want to accomplish is not that difficult. I just need an example or suggestion to help clarify it for me - I haven't had much time to...
4
by: Semi Head | last post by:
Hello folks, I'm looking for a script to validate a specific number value in a standard form input field. An example would be, if someone enters a number into a form input, I want the script to...
2
by: Doslil | last post by:
I am trying to validate the fields in my database.I have already validated the fields to check for not null.Here is what I have written for Numeric and text field. Private Function EENUM() On...
1
by: Stephen Adam | last post by:
Hi there, I have written a custom validation control which checks to see of an input field is not empty and contains only numeric data. I was using a regular expression validation control but...
6
by: goober | last post by:
Ladies & Gentlemen: I have built a form that client-side validates and posts data to a CRM beautifully in Internet Explorer (IE) 6. The problem comes in FireFox (FF) 1.5 when everything works...
0
by: Suresh.Eddala | last post by:
Hi, I am trying to do Form validation on client side by using atlas client-centric script. Grouping all the field validation by using "validationGroup" and on button click event checking the...
5
by: r035198x | last post by:
Setting up. Getting started To get started with java, one must download and install a version of Sun's JDK (Java Development Kit). The newest release at the time of writting this article is...
2
by: poornimanithya76 | last post by:
Hi, I am having grid view an my page which is having template fields(text box, check box and drop down).If user clicks on check box i need to consider text box and drop down as a required fields.i...
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
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
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...

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.