Problem with compare date

Problem with compare date

I'm trying a few weeks ago to do the following without success, if anyone can help me i will appreciate your help.

I have 3 forms one is for the employees, second are a list of projects and the third is where I assign an employee to a project.

My problems is that when the user try to assign an Employee two time in same dates i need to send an informative messages to the user, without use cancel submit (if i use this line i can see the message but can't save the record)

In this form (Assign Employee) i have two dates... Start Date and End Date, i try to compare user input Start Date if this is less or equal to this two dates then send a Message, also I try to validate if input Name is equal to Name  of the records saved in the forms, but this not work.

Here is an example of the code i try to use, i don' t understand how Zoho execute the code lines,  my problem is that always save the record and this not show me the message.

for each x in Asign_Employee
{
    startDate = input.Start_Date_assign;
    if ( input.Name_resource == Name_resource)
    {
        endDate = x.End_Date_assign;
        beginDate = x.Start_Date_assign;
        if (startDate  <=  endDate)
        {
            alert "Employee can't be assign to the same date";
        }
        else if (startDate  <=  beginDate)
        {
            alert "Employee can't be assign to the same date";
        }
    }
}

I hope someone can't help me, and thanks!