Solved

Help with controlling Textbox format, nuber of characters allowed and passing dates from calendar

Posted on 2011-09-14
12
202 Views
Last Modified: 2012-05-12
Hello,

Using a reguklare Textbox in my ASP.NET form:

1. How do I only allow users to enter "-" and "/", no space between characters and only four characters, for example:
M-55 or M/55 but not M 55 or M$557.

2. How do I display a calendar box and save date selected to a textbox in the following format:
DD/MM/YYY?

Thanks,

Victor
0
Comment
Question by:vcharles
  • 6
  • 3
  • 2
12 Comments
 
LVL 16

Expert Comment

by:disrupt
ID: 36539540
0
 
LVL 7

Accepted Solution

by:
Slimfinger earned 250 total points
ID: 36539583
How do I only allow users to enter "-" and "/", no space between characters and only four characters, for example:
M-55 or M/55 but not M 55 or M$557.
a) You can use a regular expression validator if you want to make such entries "illegal" (but typeable).
b) You can use client script (javascript, e.g.) to intercept and filter keystrokes.

How do I display a calendar box and save date selected to a textbox in the following format:
DD/MM/YYY?
Get the value from the calendar box via standard method, set the text of the textbox using one of the ToString(string format) method (such as the one from the DateTime class).
0
 
LVL 16

Assisted Solution

by:disrupt
disrupt earned 250 total points
ID: 36539726
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

Author Comment

by:vcharles
ID: 36540948
Thank you for all the comments, will get back you later today.
0
 

Author Comment

by:vcharles
ID: 36540994
Hello,

I looked at the examples but still not clear on how to implement them in my project. Can you please send me a small sample on how to use the calendar in an ASP.NET project.

Thanks,

Victor
0
 

Author Comment

by:vcharles
ID: 36541061
Hi,
Below is the code, I was using to restrict certain characters, how do I modify it to only include the following to symbols "-" and "/" and no space between characters? Quickest would be to include all possible symbols in that list and exclude the two that I want, but, s a better way than including a long list of symbols in the code?

Dim ca As Char() = {"+", "$", "/"}
Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        If ca.Contains(e.KeyChar) Then
            e.Handled = True
        End If
    End Sub

How do I include a calendar button next to my textbox and when I click on it to display the calendar to select the date and display date selected in the textbox in the format mentioned (dd/mm/yyyy). Can you please send me an example of the code.

Thanks,

Victor
0
 

Author Comment

by:vcharles
ID: 36541120
Hi again,

How do I also control input in a Textbox, to only allow number and 5b characters in the following format : XX.XX?

Thanks,

Victor
0
 
LVL 16

Expert Comment

by:disrupt
ID: 36543071
0
 
LVL 7

Expert Comment

by:Slimfinger
ID: 36589125
It seems that your #1 question was answered by several people, and not by the person you credited.  Or did I miss it?
0
 

Author Comment

by:vcharles
ID: 36589991
You are right. I'm truly sorry about that. Unfortunately I can't take back the credit, will be more careful next time.

Victor
0
 

Author Closing Comment

by:vcharles
ID: 36591976
Thank You for both solutions.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ASCX file or a newer alternative? 1 35
What .NET URL re-routing tool did I use? 2 56
How to have a gridview column with multiple items in a column row. 2 24
IIS redirect 1 68
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

773 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