Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Custom Validator
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01057025
Message ID:
01058876
Views:
20
Hey Tom,

thanks for the link.



>William;
>
>Try this link:
>
>http://msdn.microsoft.com/asp.net/articles/
>
>Client Side Development
>Get Your Client Side Script On
>
>Tom
>
>
>
>
>>Tom,
>>
>>I was planning to create a class and place javascript functions contained in methods and then invoke them as need it in my application (codebehide). But maybe I should just use plain js on the html, so for I need to set focus to the first control in my webforms.
>>
>>William
>>
>>>William;
>>>
>>>Do not take this as the last word on the subject, but I have found limitations using Javascript on the Codebehind Page, as compared to using it on the HTML Page. Additionally, my experience is that it is not as easy to use Javascript on the Codebehind Page as it is on the HTML Page.
>>>
>>>Perhaps someone else has a more positive experience with the Codebehind Page and Javascript?
>>>
>>>Tom
>>>
>>>
>>>>Hi Tom,
>>>>
>>>>Thanks a lot. You were right about CompareValidator. For some reason I thought that this control was used only to compare between to values but it also does datatype validation. So to verify that the user enter a good date I placed Compare and requiered validators.
>>>>
>>>>If I want to use javascript for another tasks do you recommend to place javascript on the asp file or "injected" on the codebehind?
>>>>
>>>>Thanks again,
>>>>
>>>>William
>>>>
>>>>>William;
>>>>>
>>>>>Could you use a CompareValidator? It is easy to set up and works well.
>>>>>
>>>>>Depending upon what Browser your audience consists of, you might consider HTML side code in vbScript or JavaScript.
>>>>>
>>>>>Here is an example in vbScript:
>>>>>
>>>>><  script language=vbScript  >
>>>>>sub txtTodaysDate_OnBlur()
>>>>>     if len(trim(frmCustomer.txtTodaysDate.Value))> 0 then
>>>>>          if Not IsDate(frmCustomer.txtTodaysDate.Value) then
>>>>>           alert ("Not a valid date") frmCustomer.txtTodaysDate.focus()
>>>>>          end if
>>>>>     end if
>>>>>end sub
>>>>>< /script >
>>>>>
>>>>>
>>>>>Tom
>>>>>
>>>>>
>>>>>>Hi All,
>>>>>>
>>>>>>I have a web form with 3 textboxes to receive dates also I have a custom validator and a method (validate_date) to validate one of the dates.
>>>>>>
>>>>>>private void Validate_date( object sender, ServerValidateEventArgs e)
>>>>>>{
>>>>>>			lblMessage.Text = "";
>>>>>>			e.IsValid = true;
>>>>>>			
>>>>>>			if ( !IsDate( e.Value) )
>>>>>>			{
>>>>>>				e.IsValid = false;
>>>>>>				
>>>>>>				cv_IssuedDate.ErrorMessage = "Invalid Date!";
>>>>>>				lblMessage.Text = "Issued Date Invalid";
>>>>>>			}
>>>>>>		}
>>>>>>
>>>>>>		public bool IsDate(string sdate)
>>>>>>		{
>>>>>>			DateTime dt;
>>>>>>			bool isDate = true;
>>>>>>			try
>>>>>>			{
>>>>>>				dt = DateTime.Parse(sdate);
>>>>>>			}
>>>>>>			catch (Exception e)
>>>>>>			{
>>>>>>				isDate = false;
>>>>>>				lblMessage.Text = e.Message;
>>>>>>			}
>>>>>>			return isDate;
>>>>>>		}
>>>>>>
>>>>>>The problem is that is always returning Invalid date even when I type a correct date
>>>>>>Ex 01/01/01 or 01/01/2000
>>>>>>
>>>>>>Any help would appreciated,
>>>>>>
>>>>>>thanks
Previous
Reply
Map
View

Click here to load this message in the networking platform