C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Javascript »

Javascript with Regular Expression


Posted Date: 06 Jan 2009    Resource Type: Code Snippets    Category: Javascript
Author: Babu AkkandiMember Level: Diamond    
Rating: 1 out of 5Points: 7



This following sample will help you, how to use Regular Expression concept in Javascrtipt.

In this Code, pattern is defined to validate the text content should start with "a" and 5 digit number.

For Example:
a00000



function validateValue()
{

// Defining Regular Expression Pattern
// This Pattern is validate the value like "a00000"

var re5digit = /^\a\d{5}$/
if (document.form1.TextBox1.value.search(re5digit) == -1) //if match failed
alert("Please enter a valid 5 digit number inside the text starts with 'a', Example: a00000")
}



to see the demo of this code, download the attachment, (it is developed using vs 2008)

Hope it Helps!

Attachments

  • Javascript with Regular Expression (24840-62329-Javascript with RegEx.zip)



  • Responses


    No responses found. Be the first to respond and make money from revenue sharing program.

    Feedbacks      
    Popular Tags   What are tags ?   Search Tags  
    Sign In to add tags.
    Javascript with Regular Expression  .  

    Post Feedback


    This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
    You must Sign In to post a response.
    Next Resource: Introduction about JScript .NET
    Previous Resource: Javascript date validation
    Return to Discussion Resource Index
    Post New Resource
    Category: Javascript


    Post resources and earn money!
     
    Related Resources



    dotNet Slackers

    About Us    Contact Us    Privacy Policy    Terms Of Use