Articles in this section
Category / Section

How to validate the fields of custom appointment form - ASP Schedule?

1 min read

The following steps show 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://asp.syncfusion.com/demos/web/Schedule/CustomWindow.aspx

Help document Location: Using Customized Appointment window: http://docs.syncfusion.com/aspnet/schedule/customization

Step 2: Add the following code examples within the style and script section.

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");  // Validates subject
            return false;
        }
    })
    $("#customdescription").focusout(function () {
        if ($.trim($("#customdescription").val()) == "") {
            $("#customdescription").addClass("validation");  // Validates 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())         // Validates 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. Then, check also for all other field validations as shown in the following screenshots.

Error in the Field value

Figure 1: Error in the Field value

 

Date time validation displayed in the alert message

Figure 2: Date time validation displayed in the alert message

 

Custom appointment form displayed without any error

Figure 3: Custom appointment form displayed without any error

 

Sample Link

CustomAppointmentFormWithValidation

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