tags:

views:

121

answers:

3

Hi,

I am using VB.net as well as Jquery Datepicker for getting dates.

In my VB.net code

<tr>
    <td>
        DateOfReceiving:
    </td>
    <td colspan="3">
        <asp:TextBox ID="DateOfReceivingTextBox" runat="server" CssClass="pastdatepicker" Text="DateOfReceiving" />
    </td>
</tr>

I want to allow enter user only todays date or past date with format dd/mm/yyyy. I want vb.net custom validation for that.

Please help to write vb.net regular expression.

Thanks!

+1  A: 

You aren't going to want to use a regular expression for this.

If you want to do this server-side, you should look into creating validation controls. I've never done this in VB.NET (simply because I've never used VB.NET - I'm more comfortable with C#), but this page appears to be a good starting point. You are going to want to inherit from and override methods in the BaseValidator class.

I don't usually write client-side code unless I have to, but it looks like jQuery supports form validation as well. However, as brad.huffman pointed out in the comments, you probably want to avoid doing date/time validation on the client side as you can't control your user's date/time settings - they could be incorrect.

Thomas Owens
Definitely going to want to do this server side as client side, you'd be relying on the user's machine to have the date set properly.
brad.huffman
+1  A: 

You can do this with a RangeValidator and a bit of VB.NET code:

<tr>    
    <td>DateOfReceiving:</td>
    <td colspan="3">
        <asp:TextBox ID="DateOfReceivingTextBox" runat="server"  
        CssClass="pastdatepicker" Text="DateOfReceiving" />

        <asp:rangevalidator runat="server" ID="DateRangeValidator"
        ControlToValidate="DateofReceivingTextBox" ErrorMessage="Date must be in the past"  
        Display="Dynamic" Type="Date"  />

    </td>
</tr>

Set the range for the validator in your code-behind, most likely in your Page_Load:

DateRangeValidator.MinimumValue = Date.MinValue.ToString("yyyy/MM/dd")
DateRangeValidator.MaximumValue = Date.Today.ToString("yyyy/MM/dd")
PhilPursglove
A: 

i need to insert huffman encoding in vb.net 2008 to give every world in any text word code for just arabic text to my project eg. احمد=001 محمد=1111 بلال=00001 and so on please take me my solution at a fast time am waiting you ahmed jadoo3 my project tommorow

ahmedjadoo3