Improve company productivity with a Business Account.Sign Up

x
?
Solved

RegularExpressionValidator Help

Posted on 2010-08-31
14
Medium Priority
?
344 Views
Last Modified: 2013-11-05
I have a regularExpressionValidator that's failing on the text below and I don't know why.  I want my validator to allow all possible characters and force a minimum of 20 characters to be entered.

My validator is:

<asp:RegularExpressionValidator ID="revJustification" runat="server" ControlToValidate="txtJustification" ErrorMessage="Please provide a longer justification." ValidationExpression=".{20}" />

The text it's failing on is:

-           submission of pdf documents (merging, partial deletion of file etc) to clients

-           conversion to good quality pdf of quotations including hyperlink
0
Comment
Question by:scross1276
  • 6
  • 4
  • 2
  • +1
14 Comments
 
LVL 22

Expert Comment

by:pivar
ID: 33568077
Hi,

Try


<asp:RegularExpressionValidator ID="revJustification" runat="server" ControlToValidate="txtJustification" ErrorMessage="Please provide a longer justification." ValidationExpression=".{20,}" />

Yours would validate exactly 20 characters.

/peter

0
 

Author Comment

by:scross1276
ID: 33568107
I actually tried that after submitting this question and I still get my error message saying the justification needs to be longer.
0
 
LVL 5

Expert Comment

by:FredTang
ID: 33568156
ValidationExpression="\w{20,}"
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 5

Expert Comment

by:FredTang
ID: 33568252
please try :
ValidationExpression=".{20,}$"
0
 

Author Comment

by:scross1276
ID: 33568377
Still no luck.  I don't get it.  I tried both of your suggestions.

<asp:RegularExpressionValidator ID="revJustification" runat="server" ControlToValidate="txtJustification"
                        ErrorMessage="Please provide a longer justification." ValidationExpression=".{20,}$" />
0
 
LVL 9

Expert Comment

by:puru1981
ID: 33568391
why you have used (.)?
0
 

Author Comment

by:scross1276
ID: 33568467
A period (.) is the regularExpressValidator option for all characters.  At least I believe so.
0
 
LVL 22

Expert Comment

by:pivar
ID: 33569974
The validator

<asp:RegularExpressionValidator ID="revJustification" runat="server" ControlToValidate="TextBox1" ErrorMessage="Please provide a longer justification." ValidationExpression=".{20,}" />           

works as intended for me in both asp.net 2.0 and 3.5

What kind of control is txtJustification?
0
 

Author Comment

by:scross1276
ID: 33570102
It's a standard textbox control.  <asp:textbox id="txtJustification" runat="Server" textMode="Multiline" />.
0
 
LVL 9

Expert Comment

by:puru1981
ID: 33570109
i usually use [0-9a-zA-z/w] for this so asked
0
 
LVL 9

Expert Comment

by:puru1981
ID: 33570165
can you share your aspx code
0
 

Author Comment

by:scross1276
ID: 33570300

<%@ Register TagPrefix="uc1" TagName="menu" Src="~/menu.ascx" %>

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="generalSoftware.aspx.cs"
    Inherits="eForms.generalSoftware.generalSoftware" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>General Software Request</title>
    <link rel="stylesheet" type="text/css" href="../site.css" />
    <link rel="stylesheet" type="text/css" href="../print.css" />
</head>
<body>
    <form id="software" method="post" runat="server">
    <uc1:menu ID="Menu" runat="server"></uc1:menu>
    <div id="content">
        <br />
        <div class="header1">
            Information Technology</div>
        <div class="header2">
            General Software License Request</div>
        <br />
        <br />
        <asp:Table ID="tblRequestInfo" runat="server" CellSpacing="2" Width="750" BorderWidth="0">
            <asp:TableRow>
                <asp:TableCell Width="300px">
                    Date of Request:
                </asp:TableCell>
                <asp:TableCell>
                    <asp:Label ID="lblRequestDate" runat="server" />
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell>
                    Requestor:
                </asp:TableCell>
                <asp:TableCell>
                    <asp:Label ID="lblRequestor" runat="server" />
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell>
                    Employee Name Needing Software:
                </asp:TableCell>
                <asp:TableCell>
                    <asp:TextBox ID="txtName" runat="server" Width="250px" />
                    <asp:RequiredFieldValidator ID="rfvName" ControlToValidate="txtName" Text="Name is required."
                        runat="server" />
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell>
                    Department of Employee Needing Access:
                </asp:TableCell>
                <asp:TableCell>
                    <asp:TextBox ID="txtDepartment" runat="server" Width="250px" />
                    <asp:RequiredFieldValidator ID="rfvDepartment" ControlToValidate="txtDepartment"
                        Text="Department is required." runat="server" />
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell>
                    Approving Supervisor:<br /><br />
                </asp:TableCell>
                <asp:TableCell>
                    <asp:DropDownList ID="ddlApprovingSupervisor" runat="server" Width="250px" />
                    <asp:RequiredFieldValidator ID="rfvApprovingSupervisor" runat="server" ControlToValidate="ddlApprovingSupervisor"
                        ErrorMessage="This field is required." InitialValue="-1" />
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell>
                    Business Unit of Employee Needing Access:
                </asp:TableCell>
                <asp:TableCell>
                    <asp:DropDownList ID="ddlBusinessUnit" runat="server" Width="325px">
                        <asp:ListItem Value=""></asp:ListItem>
                        <asp:ListItem>Corporate</asp:ListItem>
                        <asp:ListItem>Eastern Hemisphere</asp:ListItem>
                        <asp:ListItem>Manufacturing Supply Chain</asp:ListItem>
                        <asp:ListItem>Offshore Pipeline Solutions</asp:ListItem>
                        <asp:ListItem>Onshore Pipeline Solutions</asp:ListItem>
                        <asp:ListItem>Western Hemisphere</asp:ListItem>
                    </asp:DropDownList>
                    <asp:RequiredFieldValidator ID="rfvBusinessUnit" runat="server" ControlToValidate="ddlBusinessUnit"
                        ErrorMessage="BU is required." InitialValue="" />
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell>
            Software being Requested:
                </asp:TableCell>
                <asp:TableCell>
                    <asp:DropDownList ID="ddlSoftware" runat="server" Width="325px" OnSelectedIndexChanged="ddlSoftware_SelectedIndexChanged" AutoPostBack="true" />
                    <br />
                    <asp:RequiredFieldValidator ID="rfvSoftware" runat="server" ControlToValidate="ddlSoftware"
                        ErrorMessage="You must select a software title." InitialValue="" />
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell>
            <asp:label ID="lblSoftwareNotListed" runat="server" Visible="false">Software Title &amp; Price if Not Listed Above:</asp:label>
                </asp:TableCell>
                <asp:TableCell>
                    <asp:TextBox ID="txtSoftwareNotListed" runat="server" Width="200px" Visible="false" />&nbsp;<asp:TextBox ID="txtPrice" runat="server" Width="50px" Visible="false" />
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell>Business Justification for this Software:</asp:TableCell>
                <asp:TableCell>
                    <asp:TextBox ID="txtJustification" runat="server" TextMode="MultiLine" Rows="7" Columns="35"
                        MaxLength="500" /><br />
                    <asp:RequiredFieldValidator ID="rfvJustification" ControlToValidate="txtJustification"
                        Text="A business justification for this request is required." runat="server" /><br />
                    <asp:RegularExpressionValidator ID="revJustification" runat="server" ControlToValidate="txtJustification"
                        ErrorMessage="Please provide a longer justification." ValidationExpression=".{20,}" />
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell>Date Software is Needed:</asp:TableCell>
                <asp:TableCell>
                    <asp:Calendar ID="calDateNeeded" runat="server" BackColor="#585858" SelectedDayStyle-BackColor="#C90515"
                        SelectionMode="Day" TodayDayStyle-BackColor="#CFCFCF" TodayDayStyle-ForeColor="#000000"
                        CellPadding="0" CellSpacing="3" DayStyle-ForeColor="#FFFFFF" DayHeaderStyle-ForeColor="#CBCBCB"
                        DayNameFormat="FirstTwoLetters" Font-Size="8pt" TitleStyle-BackColor="#585858"
                        TitleStyle-Font-Bold="true" TitleStyle-ForeColor="#FFFFFF" OtherMonthDayStyle-ForeColor="#8E8E8E"
                        BorderColor="#000000" NextPrevStyle-ForeColor="#FFFFFF" OnSelectionChanged="calDateNeeded_SelectionChanged" />
                    <asp:TextBox ID="txtValidateCalendar" runat="server" CssClass="hideMe" />
                    <asp:RequiredFieldValidator ID="rfvCalendar" runat="server" ControlToValidate="txtValidateCalendar"
                        ErrorMessage="You must select a date." />
                </asp:TableCell>
            </asp:TableRow>
        </asp:Table>
        <br />
        <div style="text-align: center; font-size: 10pt">
            By clicking the submit button below, you acknowledge the cost of the software you
            selected, which will initially be paid for by IT, then charged back to your department
            through allocation costs.</div>
        <br />
        <div style="text-align: center">
            <asp:Button ID="btnSubmit" OnClick="btnSubmit_Click" Text="Submit Request" runat="server"
                CssClass="btn" />
        </div>
        <br />
    </div>
    <asp:TextBox ID="txtRequestID" runat="server" Visible="false" />
    <asp:TextBox ID="txtRequestDetailsID" runat="server" Visible="false" />
    <asp:TextBox ID="txtApprovalID" runat="server" Visible="false" />
    <asp:TextBox ID="txtEmail" runat="server" Visible="false" />
    </form>
</body>
</html>

Open in new window

0
 
LVL 9

Accepted Solution

by:
puru1981 earned 2000 total points
ID: 33570519
0
 

Author Closing Comment

by:scross1276
ID: 33570743
I've tried that before, with success.  The only problem is that my expression string gets very long to accomodate all of the characters users enter.  That's ok, at least it worked.  I'll go back to that.  Thank you for you sticking with this and helping me!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
When you have multiple client accounts to manage, it often feels like there aren’t enough hours in the day. With too many applications to juggle, you can’t focus on your clients, much less your growing to-do list. But that doesn’t have to be the cas…
Watch the video which demonstrates the easy migration process from GroupWise to Outlook with the help of Kernel Novell GroupWise to Outlook software. User can export single or multiple mailboxes either by Online mode or via Command line mode with ea…

588 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