I would need to allow the date to be in this format: dd/mmm/yyyy from this code here. When I select the data from the datepicker, the value appear is in "dd MMM yyyy" format.
But if I typed in the date that I want manually, eg if I typed "02032014", it just read it as it is and won't change it to "02 MAR 2014."
Javascript:
function CompareDates(id)
{
var monName = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sept", "Oct", "Nov", "Dec");
var d = new Date(id);
var curr_date = d.getDate();
var curr_month = d.getMonth(monName);
var curr_year = d.getFullYear();
return d.format(curr_date + " " + curr_month + " " + curr_year);
}
and my calendar tag:
<td>
<p:calendar
value="#{pc_Rpt2202.asat_date}"
id="rp2202_input_as_at"
styleClass="calendar"
maxlength="10"
pattern="dd MMM yyyy"
onchange="$(this).val(CompareDates($(this).val()))"
onfocus="$(this).mask('99/99/9999');"
>
<p:watermark for="rp2202_input_as_at" value="dd/MMM/yyyy" />
<f:convertDateTime pattern="dd MMM yyyy" />
</p:calendar>
</td>
May I know how can I solve it by allowing the data validation to work?
Here's an example of what I want: http://www.flyscoot.com/index.php/en/?gclid=CLvPseXn_74CFQyTjgodz5sAEQ
After I typed in the date manually, it will auto change to dd MMMM yyyy format instead of selecting it from the datepicker.