473,509 Members | 2,508 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

javascript validation for textbox

vivekgs2007
60 New Member
im new to javascript, i want a javascript validation for validating txtbox

my requirement is to enter string in txtbox in dis form only(12_A-34)

i.e first 2 digit and 1 underscore and 1 Capital letter and 1 hypen and 2 digits.

if any thing change in the format it should alert msg,

it should enter only in this (12_A-34) format only
Apr 13 '10 #1
3 2111
Dormilich
8,658 Recognized Expert Moderator Expert
that looks like a job for a Regular Expression.
Apr 13 '10 #2
vivekgs2007
60 New Member
How to do that regular expression validation
Apr 13 '10 #3
rahuljaiswal1987
23 New Member
It'll be something like this:

Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript1.2">
  2. function checkpostal(){
  3. var re5digit=/^\d{5}$/ //regular expression defining a 5 digit number
  4. if (document.myform.myinput.value.search(re5digit)==-1) //if match failed
  5. alert("Please enter a valid 5 digit number inside form")
  6. }
  7. </script>
  8.  
  9. <form name="myform">
  10. <input type="text" name="myinput" size=15>
  11. <input type="button" onClick="checkpostal()" value="check">
  12.  
  13. </form>

Its a validation code for a 5 digit number. You just need to change the logic according to your need.



For further help refer this link
Apr 13 '10 #4

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

Similar topics

2
17507
by: Matthew Wieder | last post by:
Hi - I'm trying to do client-side validation of the text in a Asp.Net textbox control using javascript. My page has the following: <form id="Form1" method="post" runat="server" onsubmit="return...
2
13242
by: techfuzz | last post by:
I scoured this group and others looking for the best way to disable a button after the first click to prevent multiple submissions, but never did find anything that worked like they said it would. ...
2
9843
by: Dot net work | last post by:
Hello. Say I have a .net textbox that uses a .net regularexpressionvalidator. If the regular expression fails, is it possible to launch a small client side javascript function to do something,...
3
1746
by: Ronan Dodworth | last post by:
Hi there I'm having a little bit of a problem with my customvalidator control. The problem is the javascript runs fine on my local webserver IIS but not when I post it to the web hosting server....
0
1506
by: Caesar Augustus | last post by:
I'm having a problem with two different javascript controls in my app. The first chuck of javascript that I pasted into my app is the client-side calendar control popup which works fine when first...
1
2843
by: MattB | last post by:
I have a page with dual controls for a person to enter their height and weight. The dual controls are for English and metric units, and Javascript onChange events handle populating the other...
1
5262
by: cemcat | last post by:
Hello, We have an ASP.NET 2.0 (C#) web form that contains a textbox for users to enter multiple e-mail addresses separated by semicolons. We need to validate that each individual e-mail address...
8
1195
by: Grant Merwitz | last post by:
hi I am using Javascript to do my validation This is so i can display a loading message after a form is submitted. Now, currently i do so like this. I have a button, textbox and label like...
1
1919
by: karen987 | last post by:
I have a comment form, on a news website, ASP page, which users fill in and it adds comments to a news article. The reader clicks on a headline and the comments open up in a new window. It already...
4
1207
by: Andy B | last post by:
How do you add javascript to a page from codebehind? I have a method I am working on that has a few conditions in it: 1. if either 1 or both WordTextBox or DefinitionTextBox is empty, show a...
0
7135
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
7342
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
7410
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...
1
7067
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5650
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,...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1570
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
440
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.