Using AJAX MaskedEditExtender And MaskedEditValidator To Validate The Phone?
Feb 6, 2010
I have text box to enter a phone number. I'm using AJAX MaskedEditExtender and MaskedEditValidator to validate the phone.I have no problem with mask but the problem nothing happen when I enter for example only 3 number then lose the focus but as soon the focus on I will see the error message and it will disappear as soon as I write one number.
all what I want to get the error message if the user did not enter 9 numbers after lose the focus.
here is my code: <asp:TextBox ID="txtHomePhone" runat="server" ontextchanged="txtHomePhone_TextChanged"></asp:TextBox>
I am not sure what I am doing wrong. I am trying to validate a field called "RIF" My mask is (letter J dash eight digit dash one digit) J-43434545-9 I tried various Mask and Validation Expressions When I enter the correct it considers it invalid
have a C#/ASP.NET web application that contains DetailsView controls that are used for CRUD operations through the EntityDataSource and Entity Framework. Unfortunately I'm not sure which forum would be best to post this under, since I am wondering whether either the MaskedEdit AJAX controls or Entity Data Model could be configured to allow for this.ProblemThe Entity Framework requires time fields to be of time(7) data type, which must be entered as 24-hour time, with seconds (e.g. '09:30:00'). However, I want the time entered in 12-hour time and without seconds (e.g. '9:30 AM'). Is there a way I can configure the MaskedEditExtender and/or MaskedEditValidator to allow for this. What I was thinking is possibly using the AutoComplete portion of this control to fill in the remaining portions (i.e. seconds) that the user does not enter, but which the EF requires. Either that or can the Entity Data Model or something else be configured to allow for this?Existing Code
I have the following tabpanel (it actually contains a bit more content, but that content doesnt influence my issue):
When I remote the MaskedEditExtender and MaskedEditValidator, it doesnt show that (undesired) behaviour anymore.Is there something special these controls do that cause them to refresh? Is there a workaround for this?
Breaking out the required field validation helped me get the date textbox to behave the way I need. Just positioning validation messages and such. Behavior I like here is that TextBox has no mask to start (focus off of textbox). When you put the cursor in the textbox or the textbox gets focus then the mask shows up: __/__/____. As you type the underscore placeholders dissapear but the '/' chars stay in place.
And finally, this is key, when you have a correct date and take the focus away from the text box the dashes stay in place. I just realized that is because the date mask seems to fill in the blank spaces with the current date. I cannot get this behavior with a phone. Granted there is no phone mask type. Here is the phone code:
I have tried MaskType set to number but it doesn't change the behavior. Right now the dashes dissapear when I take the focus off of the phone textbox. One thing I noticed with date is that if it is incomplete when it loses focus it fills in the rest with the current date values. Since there is no Phone mask type that behavior is not built in. Does anyone know how to set a default behavior so if you type in 55 in would automatically finish? 555-55-5555 And when you take the focus off it would keep the dashes. But if the textbox is empty I want with no focus the mask should dissapear completely.
I want a TextBox with a mask like (xxx) xxx-xxxx using a MaskedEditExtender. I tried to set up the mask property to "(999) 999-9999" or "(999) 999-9999" but nothing works. It there a way I can have the mask I want?
I have a textbox and an image on a website. When I press the image, the calendar is extended (works!); also, I use a masked edit extender to show the right mask (works!)But when I use the MaskedEditValidator to get the date input validated, this is where I get stuck :s (doesn't work [:S])I added my very simple demo code below, can someone tell me what I am doing wrong?For example, when I input a date like 99/99/9999, the Validator doesn't complain, but it isn't a valid date :sMy code:
I am Using "MaskedEditExtender" along with "MaskedEditValidator" in my page with a textbox. it is not working and showing the NullReference exception. the call stack showing the following details
[NullReferenceException: Object reference not set to an instance of an object.] AjaxControlToolkit.MaskedEditValidator.OnPreRender(EventArgs e) in C:UsersswaltherProjectsAspNetAjaxReleases30930AjaxControlToolkitSourceAjaxControlToolkitMaskedEditMaskedEditValidator.cs:384
I am using the MaskedEditExtender and MaskedEditValidator, but have experienced some strange behaviour. (See code example below). When entering a date into the textbox this is what I see:
1. The mask
2. Entering the date and time e.g. "19-01-1980 10:11:12"
3. When removing focus from the textbox the result is: "19-01-1980 19:01:19"
The six first digits of the date is copied as the time? If entering a day of the month larger than 23 and any given month, year and time (eg. 25-10-1980 12:12:12) the validation fails as the six first digits are copied to the time resulting in a time 25:10:19 which obviously is not valid.
I have downloaded the AJAX toolkit sample code and experience the exact same behaviour. When running the AJAX Toolkit samples from[URL] works fine!
Additinal info: Culture is danish (DateTime format is dd-MM-yyyy hh:mm:ss). Tried changing my systems culture to en-US but same behaviour.
I have 2 scenarios here for using the MaskedEditValidator for a date field. I'll start with the easier one first.
1) I have a date field. I want to set the MaskedEditValidator's minimum value property to TODAY's date. So for example, if the user enter's a date earlier than today, the AJAX control will show a message stating "you can't input a date earlier than today".
2) I have 2 date fields - 1st one is 'start date' and 2nd one is 'end date'. I want to set the MaskedEditValidator for the end date so that the minimum value property is the date from the 'start date' field. So this way, the user can't enter a date in the 'end date' field that is earlier than what is in the 'start date' field.
I am facing a problem when using ajaxcontroltoolkit 30305121 or 3.0.20229.0 version. The following code is using calendarextender which is format with 'yyyy/MM/dd' and then the mask of maskededitextender is '9999/99/99', it is working fine when I am using '99/99/9999', but it cannot work with '9999/99/99'.
I have a panel, with several textboxes and an ImageButton inside of it. One of the textboxes has a MaskedEditExtender and a MaskedEditValidator associated with it. When I hit enter from any other textbox besides the one with the MaskedEditValidator the defaultbutton that is defined in the Panel's DefaultButton property handles the enter key.However, when I am in the textbox with the MaskedEditValidator, the first button on the form is receiving the enter key. Now, if I take the MaskedEditExtender off of the page, and just leave the MaskedEditExtender, everything behaves as it should.Can anyone offer any insight into how I may get this to work properly, or is this a known bug?I tried searching the forums and found a similar post, but no conclusion was ever reached.
Protected Sub MaskedEditValidator_MaskedEditServerValidator(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ServerValidateEventArgs) Handles MaskedEditValidator.MaskedEditServerValidator If Me.rbStlRentalInclu.checked Then e.IsValid = False End If End Sub
The MaskedEditValidator did not show Invalid Message after postback, why?
I can't get the MaskedEditValidator to work with the ValidationSummary in ways of separate information: a '*' next to the textbox, and a string message in the validator.
Question: With 'standard' validation controls, they put the "ErrorText" value in the ValidationSummary, and the "Text" value right next to the TextBox. But the AJAX Validators don't handle different messages for next to the textbox and summarry.
Am I doing something wrong? Or is it just not possible.
Something "weird" is happening with my ASP.NET application. I have a MasterPage with WebForms, and inside one of them, I have an ASP TextBox which is controlled by the MaskedEditExtender/MaskedEditValidator couple. Underneath, I have a GridView with 2 columns, an Edit ASP Command Field, an ItemTemplate which contains an ASP ImageButton with a Delete CommandName linked to a GridViewDelete Event through the OnRowDeleting attribute. The GridView is binded with SQL Server data while the page is loading.
It appears that once the page is loaded, if I want to delete a row by clicking on the ASP ImageButton, nothing appears. I have first to do something else with the GridView (raise an Edit Event for example), then it's accessible. I try different stuff to catch the source of the problem, and the "weird" part appeared when I deleted the MaskedEditValidator, just keeping the MaskedEditExtender : the Delete ASP ImageButton worked since the page loads!
I want masked ComboBox, so I use a MaskedEditExtenderwith a ComboBox. The two controls came from the ajax control toolkit. But I got an error: "Unable to cast object of type 'AjaxControlToolkit.ComboBox' to type 'System.Web.UI.WebControls.TextBox'". Is there a way a can use a MaskedEditExtender with a combo box?
I'm having a really strange issue with the MaskedEditExtnder. I've attached some markup for one of the textboxes. I'm using a MaskedEditExtender and MaskedEditValidator along with a CalendarExtender so the user has the option to type the date or click on an image and pick the date.
So, if I enter/pick a date then select a control that forces a postback (usually a dropdownlist but not always) when the page is returned the focus goes back to the textbox I just entered the date in. So what about the MaskedEdit, MaskedEditValidator, CalendarExtender would cause the page to return focus to the control being extended? See markup below - am I missing something??
I've played around a bit with the MaskedEditExtender.. However when looking into the
sample web site you'll see, that the cursor is placed just before the decimal-sign, when entering the number field. I like that behavior, but I cannot get it to work. There is no property setting this, as I see it.
Has anyone managed to set the focus-position in MaskedEditExtender like at the sample web site?
I have a textbox with MaskedEditExtender.In Which,I've set mask as '999.99'.Problem is ,When i get the decimal value from database and assign to textbox.It shows the wrong value.For example,When I assign the decimal value 89.95 from database.textbox shows 899.50 instead of 89.95.
I'm having a issue with a MaskedEditExtender, I am using it for a datetime field with the sqltable field definition as smalldatetime, I have several error messages such as emptyvalue error message, minimium value error message along with a few others.
Everything works fine until i put a maximium value, on selecting either insert or edit it throws the error even if the date entered is between the minimium value and the maximium value and will not go away. As you are aware smalldatetime has a max value of 06/06/2079 which won't be a issue in my lifetime but for validation purposes I want to make sure the user doesn't accidentally enter a value larger than the max value thus causing an error on insert or edit.