How can I prevent the user from selecting a date in the calendar field


Tutorials - Tutorials

User Rating: / 0
How can I prevent the user from selecting a date in the calendar field

In a previous article we have described how to disable all the dates before today's date from the RSForm!Pro Calendar. In this article we will describe how to disable the date selection from a specific point forward(for example 2 days from today's date).

The first thing you need to do is to set the minimum date of the calendar field to a specific date, for example 01/01/2012 (the 1st of January 2012). After you have done this you will need to add a custom script in "Scripts called on form display" (you can find this field by going to Components > RSForm!Pro > Manage forms > select your form > Properties > PHP Scripts) that will take the minimum date and replace it with your custom date. The script presented below will disable the date selection for any dates that are before two days starting from the current date:

  $futureDate = date('m/d/Y', strtotime("+2 days")); $formLayout = str_replace("{'mindate': '01/01/2012'}", "{'mindate': '".$futureDate."'}", $formLayout);  

The first line will calculate the date two days from the current date using standard PHP functions and the second line will replace the default minimum date that you have set previously with your calculated date.

You can also control the month the calendar displays when the browse button is clicked by adding a new parameter to the calendar: pagedate . In order to control the month that is displayed when the calendar is opened you could try using:

  $replace = "extra: Array({'mindate': '01/01/2012'})"; $with = "extra: Array({'mindate': '01/01/2012', 'pagedate': '10/2012'})"; $formLayout = str_replace($replace, $with, $formLayout);  

As of RSForm!Pro rev. 46, we have added the possibility to insert custom PHP scripts in the calendar field's Min Date and Max Date areas. The method described above is equivalent to the following example:


Adding the following code in the calendar field's Min Date tab will set the current date as the minimum selectable date for the calendar field:

return date('m/d/Y');

About Us

Royal Developer Top three Web Designing and Web Development Company in Dehradun, Uttarakhand, India. Royal Developer Best SEO Company in Dehradun takes pride in its philosophy of 'Employee First' which empowers to create a real value for the customers. Royal Developer can offer Best and cheap Website Development Software Development & SEO Services. We are the Best service Provider of SEO, SEM, SMO ServicesCompany in Uttarakhand. Web Designing Course in Dehradun, Web Designing Classes in Dehradun, Web Design Training Institute in Dehradun, Web designing institute in dehradun, Best institute for web designing in dehradun, Web development training in dehradun, Web development course in dehradun, Web Designing Training in Dehradun.


- Contact Information - 

Add : RDIT Services Pvt Ltd, 3rd Floor, RGM Plaza, Above Chandu Canteen,
          23 Chakrata Road, Dehradun - 248001, Uttarakhand, India

Email : 


 : +91 8171200108, +91 8979462451,
                                  +91 7895753921

Quick Enquiry Form

Enter your full name

Enter your valid email address

Enter your correct mobile number

Invalid Input

Your Message
Invalid Input

Enter Code
Enter Code
  RefreshInvalid Input


You are here: Home Tutorials How can I prevent the user from selecting a date in the calendar field