Hi
I want to validate that the user does not enter any previous date.
Here is the code that takes the date input from user
<field name="appDate" type="digits?length=8">
<prompt>
<voice name="crystal">
<break size="medium" />
Enter the date in year month day format, of your appointment.
For example for 18 Feburary 1983 enter <say-as type="acronym">19830218</say-as>
</voice>
</prompt>
<filled>
<assign name="appointmentDate" expr="appDate.substr(4,2)+'/'+appDate.substr(6,2)+'/'+appDate.substr(0,4)"/>
</filled>
</field>
Now how and where to validate the user date is not less than previous date??
Regards,
Amit
We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics
Validate date entered
-
- Posts: 53
- Joined: Sun Feb 15, 2009 11:42 pm
- Contact:
IVR code for validating a date entered
Hi,
You can use the IVR tag, <if>, to set up conditionals within your VXML script. Use this IVR code for example.
validatedate.php:
Hope this helps.
Regards,
Plum Support
You can use the IVR tag, <if>, to set up conditionals within your VXML script. Use this IVR code for example.
validatedate.php:
Code: Select all
<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");
?>
<vxml version="2.0">
<form>
<var name="prevDate" expr="19820118"/>
<field name="appDate" type="digits?length=8">
<prompt>
<voice name="crystal">
<break size="medium"/>
Enter the date in year month day format, of your appointment.
For example for 18 Feburary 1983 enter <say-as type="acronym">19830218</say-as>
</voice>
</prompt>
<filled>
<if cond="appDate > prevDate">
<assign name="appointmentDate" expr="appDate.substr(4,2)+'/'+appDate.substr(6,2)+'/'+appDate.substr(0,4)"/>
<prompt>
The appointment date is <value expr="appointmentDate"/>.
</prompt>
<else/>
<prompt>
You have entered a previous date.
</prompt>
</if>
</filled>
</field>
</form>
</vxml>
Regards,
Plum Support
Last edited by support on Wed Feb 24, 2010 1:11 pm, edited 4 times in total.
Plum Support
http://www.plumvoice.com
http://www.plumvoice.com
-
- Posts: 53
- Joined: Sun Feb 15, 2009 11:42 pm
- Contact:
Validate date entered
Thanks for thesolution, but what i was wondering is that how will i get the current date & time to check if the date entered is not less than todays date and current time
regards,
amit
regards,
amit
support wrote:Hi,
You can use the <if> tag to set up conditionals within your VXML script. For example:
validatedate.php:
Hope this helps.Code: Select all
<?php header("Content-type: text/xml"); echo("<?xml version="1.0"?>\n"); ?> <vxml version="2.0"> <form> <var name="prevDate" expr="19820118"/> <field name="appDate" type="digits?length=8"> <prompt> <voice name="crystal"> <break size="medium"/> Enter the date in year month day format, of your appointment. For example for 18 Feburary 1983 enter <say-as type="acronym">19830218</say-as> </voice> </prompt> <filled> <if cond="appDate > prevDate"> <assign name="appointmentDate" expr="appDate.substr(4,2)+'/'+appDate.substr(6,2)+'/'+appDate.substr(0,4)"/> <prompt> The appointment date is <value expr="appointmentDate"/>. </prompt> <else/> <prompt> You have entered a previous date. </prompt> </if> </filled> </field> </form> </vxml>
Regards,
Plum Support
IVR code to validate date entered
Hi,
You can use the following IVR example of IVR code that uses the IVR tag, <if>, to help you achieve this.
validatedate.php:
Hope this helps.
Regards,
Plum Support
You can use the following IVR example of IVR code that uses the IVR tag, <if>, to help you achieve this.
validatedate.php:
Code: Select all
<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");
?>
<vxml version="2.0">
<form>
<script>
var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
if (month < 10){
month = "0" + month;
}
if (day < 10){
day = "0" + day;
}
currentTime = year + month + day;
</script>
<field name="appDate" type="digits?length=8">
<prompt>
<voice name="crystal">
<break size="medium"/>
Enter the date in year month day format, of your appointment.
For example for 18 Feburary 1983 enter <say-as type="acronym">19830218</say-as>
</voice>
</prompt>
<filled>
<if cond="appDate > currentTime">
<assign name="appointmentDate" expr="appDate.substr(4,2)+'/'+appDate.substr(6,2)+'/'+appDate.substr(0,4)"/>
<prompt>
The appointment date is <value expr="appointmentDate"/>.
</prompt>
<else/>
<prompt>
You have entered a previous date.
</prompt>
</if>
</filled>
</field>
</form>
</vxml>
Regards,
Plum Support
Plum Support
http://www.plumvoice.com
http://www.plumvoice.com