Wrox Programmer Forums
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 8th, 2006, 09:12 PM
Registered User
 
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default Regula Expression.

Hi
I m using following regular expression for allowing only characters, numbers and _ , - , and /. but not working can anyone tell me what's wrong?

Thanks in advace.
-------------------------
    var charpose;
    charpose = x.txtPrjNo.value.search("[^A-Za-z0-9/-_]")
    if (x.txtPrjNo.value.length > 0 && charpose >= 0)
    {
        alert("Only Charaters,Numbers,_,/ and - are allowed in Project Number. Remove Extra Spaces.")
        return false;
    }
-------------------------


Rupen Anjaria.:)
------------------
We CAN'T avoid problems, but can solve it.
 
Old March 9th, 2006, 12:59 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hi Rupen!!
plz try this code
<script>
function regTest()
{
 var charpose;
 x=document.myform
var objRegExp=/^[a-z\d\-\_\/]+$/i
    charpose =objRegExp.test(x.txtPrjNo.value)
    if (!charpose)
    {
        alert("Only Charaters,Numbers,_,/ and - are allowed in Project Number. Remove Extra Spaces.")
        return false;
    }
}
</script>
<form name="myform">
<input type=text name=txtPrjNo />
<input type=button name=chkReg value=Test onclick="regTest()"/>
</form>

Hope this will help you.


Cheers :)

vinod
 
Old March 9th, 2006, 06:34 PM
Registered User
 
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default

Fine...working..

Rupen Anjaria.:)
------------------
We CAN'T avoid problems, but can solve it.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Message> in query expression <expression>. (Error ybg1 Access 5 July 15th, 2007 05:42 AM
sort by expression ronisc XSLT 1 December 17th, 2006 02:36 PM
Validator expression Maxxim ASP.NET 1.0 and 1.1 Professional 1 December 3rd, 2006 07:07 AM
Regular expression C# radhakrishnan1976 General .NET 1 February 19th, 2006 01:11 AM
'OR' Expression saturdave ASP.NET 1.0 and 1.1 Basics 2 February 17th, 2004 03:03 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.