Articles in this section
Category / Section

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

1 min read

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

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

Sample Location:

https://mvc.syncfusion.com/demos/web/schedule/customappwindow

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

https://help.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 in Schedule

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


Conclusion

I hope you enjoyed learning about how to validate the fields of custom appointments window in EJMVC Schedule.

You can refer to our ASP.NET MVC Schedule feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our ASP.NET MVC Schedule example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied