This is a migrated thread and some comments may be shown as answers.

[Solved] Remote Validation

6 Answers 151 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
HoC
Top achievements
Rank 1
HoC asked on 21 Jul 2011, 08:42 PM
Hello, I am having an issue using remote validation and the datePicker control.  Basically my method won't fire right away when I change the date using the drop down calendar.  What happens is I change the date using the drop down calendar, change focus to another control, click back inside the datePicker(but change nothing) then back into another control and then my method will fire.  If I just change the date inside the textbox and change focus to another control my method fires no problem.

Is there a certain way I need to interact with this control to enable my remote validation to work correctly? 

Here is my model code for the property using remote validation:

<Remote("CheckAge", "Contact", "Invalid date of birth")> _
<DataType(DataType.Date)> _
<Display(Name:="DateOfBirth", ResourceType:=GetType(Resources._Global))> _
Public Property DateOfBirth As Nullable(Of Date)
    Get
        Return Contact.DateOfBirth
    End Get
    Set(ByVal value As Nullable(Of Date))
        Contact.DateOfBirth = value
    End Set
End Property

Here is my method in the Controller:

Public Function CheckAge(DateOfBirth As String) As JsonResult
     'Do some validation....
 
      'Return result
      Return If(DateOfBirth Is Nothing, Json(True, JsonRequestBehavior.AllowGet), _
               Json(String.Format("{0} is not available.", DateOfBirth), JsonRequestBehavior.AllowGet))
End Function


Any Advice would be much appreciated!

6 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 22 Jul 2011, 08:34 AM
Hello Priester,

 
Unfortunately, this is not a known issue. Could you please send us a simple test project, which reproduce the depicted issue? Thus I will be able to observe it locally and advice you further.

Best regards,
Georgi Krustev
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
HoC
Top achievements
Rank 1
answered on 22 Jul 2011, 02:26 PM
Unfortunately I don't have time at the moment to create a sample project reproducing what I have done.  The only other information I left out in my previous post is that I am using a telerik mvc grid with a popup editor that uses it's own Template. On the template is the datePicker control I am having issues with.
0
Georgi Krustev
Telerik team
answered on 25 Jul 2011, 09:23 AM
Hello Priester,

 
There should be no issues with this scenarios. I was not able to reproduce the issue related with the selected date from calendar. Remote validation fires correctly on my end. I will need test project which reproduces the depicted issue in order to review it locally and advice you further.

Kind regards,
Georgi Krustev
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
HoC
Top achievements
Rank 1
answered on 25 Jul 2011, 02:32 PM
Do you have a sample project I could see?  Perhaps it is something small that I missed.  i'm using VS2010 for this project.

Thank you!
0
Georgi Krustev
Telerik team
answered on 29 Jul 2011, 09:18 AM
Hello Priester,

Here is a test project which shows how to implement remote validation.

Greetings,
Georgi Krustev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

0
Nandha Kumaran
Top achievements
Rank 1
answered on 18 Oct 2012, 02:01 AM
Georgi Krustev

I have a scenario where in the Telerik datepicker is not firing the remote validation when I select a date from the datepicker (which is the on change event of datepicker). Once it fires the validation and it has the value of the previously selected date.

It works when i enter the value in the text box of the date picker and hit tab.

My code is

view.cshtml

@Html.EditorFor(model => model.InjuredDOB)
@Html.ValidationMessageFor(model => model.InjuredDOB)

Model.cs

 

[

 

DataType(DataType.Date)]

 

[

 

Display(Name = "Date Of Birth")]

 

[

 

Remote("ValidateInjuredDOB", "Case", HttpMethod = "Post", ErrorMessage = "Invalid")]

 

 

 

public DateTime? InjuredDOB { get; set; }

controller.cs

 

 

 

 

public

 

 

ActionResult ValidateInjuredDOB(string injuredDOB)

 

{

 

 

if (NotGreaterThanToday(injuredDOB))

 

 

 

    return Json(true);

 

 

 

return Json(false);

 

}

 

 

At the moment the Jquery version im using is jquery-1.5.js.

Kindly provide any workable solution.

Regards
Nandha

Kindly

Tags
Date/Time Pickers
Asked by
HoC
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
HoC
Top achievements
Rank 1
Nandha Kumaran
Top achievements
Rank 1
Share this question
or