Solved

500 points --- NIC no. Validation

Posted on 2004-10-18
4
856 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

910 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now