Code behind ‘define public var Protected StartDate As String Protected EndDate As String ‘define other var Dim sDate = Request.Form(“startDateTbx”) Dim eDate = Request.Form(“endDateTbx”) Dim r As Regex r = New Regex(“^(0[1-9]|[1-9]|1[012])/(0[1-9]|[1-9]|[12][0-9]|3[01])/20\d\d$”) ‘run validation If sDate = “” Then startDateLbl.Text = “Required” ElseIf Not r.Match(sDate).Success Then startDateLbl.Text = “Invalid date. Use mm/dd/yyyy.” Else startDateLbl.Text = […]
Archive for the 'Validation Controls' Category
Captcha – VB.NET
Email form <tr> <td></td> <td></td> </tr> <tr> <td></td> <td><img style=”WIDTH: 119px; HEIGHT: 34px” alt=”” src=”Captcha.aspx” /> <a href=””>Can’t Read?</a></td> </tr> <tr> <td></td> <td><asp:textbox runat=”server” ID=”txtcaptcha”></asp:textbox></td> </tr> <tr> <td></td> <asp:ImageButton ID=”ContactSeller” CausesValidation=”True” runat=”server” ImageURL=”/images/buttons/btn_submit.gif” /></td> </tr> Email page code behind …. Dim captchaStr As String = Session(“randomStr”) Dim captchaTxt As TextBox = ContactSeller.FindControl(“txtcaptcha”) If captchaStr captchaTxt.Text.ToString […]
Count number of characters in textbox
Markup Page <strong>Required Info:</strong> <asp:Label ID=”TotCharReqInfo” runat=”server” ></asp:Label> <strong>Body Length:</strong> <span id=”BodyLength”>0 <strong>Total Length:</strong> <span id=”TotLength”> <asp:Label ID=”TotLengthLbl” runat=”server” ></asp:Label> <strong>Left:</strong> <span id=”CharLeft”> <asp:Label ID=”ChLeft” runat=”server” ></asp:Label> <asp:TextBox id=”txtInputOnln” runat=”server” TextMode=”MultiLine” Width=”300px” Height=”90px” MaxLength=”350″ onKeyUp=”Count(this,350)” onChange=”Count(this,350)”/> Click to read more… <script type=”text/javascript”> var ChLeftVar = “<%=CharLeftInt %>”; var ChLeftOut var ChLefVar2 function count(clientId) { var txtInputOnln = […]