We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to validate the fields of Custom Appointment window in EJMVC Schedule?

Platform: ASP.NET MVC |
Control: Schedule |
Published Date: December 12, 2014 |
Last Revised Date: May 23, 2019

The following steps illustrate how to validate the fields added within the Schedule Custom Appointment window.

Step 1: Create a Schedule sample with Custom Appointment window by referring to the following links,

Sample Location:

http://mvc.syncfusion.com/demos/web/Schedule/CustomAppWindow

Help document Location: [Refer to the document under the topic – “Using Customized Appointment window”]

http://docs.syncfusion.com/aspnetmvc/schedule/customization

Step 2: Create the necessary customization Style class and add it to the required fields within the Custom Appointment window for validation purpose as follows.

CSS

<style>
    .error {
        background-color: #FF8A8A;
    }
    .validation {
        border-color: red;
    }
</style>

Javascript

<script type="text/javascript">
    $("#subject").focusout(function () {
        if ($.trim($("#subject").val()) == "") { 
            $("#subject").addClass("validation");  // Validation for subject
            return false;
        }
    })
    $("#customdescription").focusout(function () {
        if ($.trim($("#customdescription").val()) == "") {
            $("#customdescription").addClass("validation");  // Validation for description
            return false;
        }
    })
    $("#EndTime").focusout(function () {
        if (new Date($("#EndTime").val()).getDate() >= new Date($("#StartTime").val()).getDate()) {
            if (new Date($("#StartTime").val()).getTime() >= new Date($("#EndTime").val()).getTime())         // Validation for Time Interval
                alert("End Time value is less than the Start Time value");
        }
    })
</script>

Step 3: Now run the sample. Open the appointment window, click the submit button without filling the subject and description fields. Also check for all other field validations as displayed in the following screenshots.

Border is displayed in red color as field value is null

Figure 1: Border is displayed in red color as field value is null

Date time validation displayed in the alert message

Figure 2: Date time validation displayed in the alert message

Custom appointment form displaying without any errors

Figure 3: Custom appointment form displaying without any errors

Sample Link:

CustomAppointmentWindowSampleWithValidation

2X faster development

The ultimate ASP.NET MVC UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon