Solved

500 points --- NIC no. Validation

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

770 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