Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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 November 16th, 2005, 08:00 AM
Authorized User
 
Join Date: Aug 2005
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default Validations in dataGrid

how i can do d validations for input text fields that come when i do edit command in datagrid.
for e.g. i need to validate a input text box text for not to be special char. when i do update.


Please tell me how can i write function for custom validator to restrict special char.s


function fn_isspChar(source, arguments)
            {
                var CheckArr = new Array("'","`","%","@","!","#","$","&","*","(",")", "[","]","{","}","^","#","&","\"","-","=","|","+",",");

                for(i=0;i<CheckArr.length;i++)
                {
                    if(arguments.Value.indexOf(CheckArr[i]) >=0)
                    {
                        //alert("cannot contain " + CheckArr[i]);
                         arguments.IsValid=false;

                        t = eval("document.all." + source.controltovalidate);
                        t.focus();
                        t.select();
                        //break;
                    }

                    else
                    {
                        arguments.IsValid=true;
                    }
                }
            }


i've written this function.
it works pretty gud when i put alert...
but it takes only last special char in the array "CheckArr " for check when i go for setting "IsValid" i.e. ","
 
Old December 7th, 2005, 08:17 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

Have you tried using the built-in regular expression object that is part of .NET?

Here is the one I'm using to validate an email text box. You can look up the correct regular expression syntax you're looking for once you get this validator to work for you.

<asp:RegularExpressionValidator ID="regexEmail" Display="Dynamic" Runat="server" ControlToValidate="txtUserEmail" ValidationExpression="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" ErrorMessage="&nbsp;&nbsp;Please enter a valid email address." />








Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with validations ashokparchuri General .NET 1 April 14th, 2005 08:20 AM
Validations... Flunders Beginning VB 6 3 September 29th, 2004 07:09 AM
Validations through ASP ashu_gupta75 Classic ASP Basics 7 April 21st, 2004 06:07 AM
Validations not working Ajay Jain ASP.NET 1.0 and 1.1 Basics 1 February 24th, 2004 01:16 PM





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