Solved

500 points --- NIC no. Validation

Posted on 2004-10-18
4
987 Views
Last Modified: 2006-11-17
Hi,

I have to validate a text field for a NIC no. which is in a specified format. That is,

x-xxxx-xxxx-x

Can anyone let me know how to validate it for this format as such that only numbers in this format could be submitted for the form.

Thanks,

Khurram.
0
Comment
Question by:khurram007
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 12339860
NIC is the NetworkInterfaceCard?
Do you check MAC address in hex or do you check IP address in four decimal octets with dots?
0
 
LVL 2

Author Comment

by:khurram007
ID: 12339980
NIC here is for National Identity Card.

Don't focus on NIC just focus on the format I want in the text box.

Thanks,

Khurram
0
 
LVL 2

Author Comment

by:khurram007
ID: 12340859
Any suggestions???
0
 
LVL 25

Accepted Solution

by:
devic earned 500 total points
ID: 12340877
easy:
===============
<script>
//x-xxxx-xxxx-x
function checkThis(obj)
{
      if(!obj.value.match(/^\d-\d{4}-\d{4}-\d$/))
      {
            alert("enter right format:x-xxxx-xxxx-x")
      }
}
</script>
<input value="23" onblur=checkThis(this)>
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question