Calendar: An error appears in the JS console when an invalid date is entered into a p:calendar textbox
See original GitHub issueDescribe the defect
An error appears in the JS console when an invalid date is entered into a p:calendar textbox.
This is a regression in PrimeFaces 8.0 – it does not happen with PrimeFaces 7.0.
Reproducer
- Build the attached project and deploy the war to tomcat/webapps
Environment:
- PF Version: 8.0
- JSF + version: Mojarra 2.2.20
- Affected browsers: ALL
To Reproduce
- Visit http://localhost:8080/calendar-issue-1.0.0/calendar.jsf
- Show the JS console
- Pick a date with the mouse
- Enter
12/34/5678
into the field and tab-out (blur) the field
Expected behavior There will be no JS errors in the console.
Defect behavior
If the defect still exists, then the following error will appear in the JS console:
VM210:1 Uncaught SyntaxError: Unexpected token '?'
at b (jquery.js.jsf?ln=primefaces&v=8.0:2)
at Ie (jquery.js.jsf?ln=primefaces&v=8.0:2)
at k.fn.init.replaceWith (jquery.js.jsf?ln=primefaces&v=8.0:2)
at Object.updateElement (core.js.jsf?ln=primefaces&v=8.0:18)
at Object.doUpdate (core.js.jsf?ln=primefaces&v=8.0:18)
at Object.handle (core.js.jsf?ln=primefaces&v=8.0:18)
at Object.<anonymous> (core.js.jsf?ln=primefaces&v=8.0:18)
at c (jquery.js.jsf?ln=primefaces&v=8.0:2)
at Object.fireWith [as resolveWith] (jquery.js.jsf?ln=primefaces&v=8.0:2)
at l (jquery.js.jsf?ln=primefaces&v=8.0:2)
Example XHTML
<html xmlns="http://www.w3c.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head/>
<h:body>
<h:form id="f1">
<h:panelGroup id="dateOfBirthField" layout="block">
<p:calendar id="dateOfBirth" label="Date of Birth"
required="true"
pattern="MM/dd/yyyy" showOn="button"
value="#{calendarBacking.dateOfBirth}">
<f:convertDateTime pattern="MM/dd/yyyy"/>
<p:ajax update="dateOfBirthField"/>
<p:ajax event="dateSelect" update="dateOfBirthField"/>
</p:calendar>
</h:panelGroup>
<hr/>
<p:commandButton action="#{calendarBacking.submit}" update="f1"
value="Submit"/>
</h:form>
</h:body>
</html>
Example Bean
import javax.faces.bean.ManagedBean;
import java.util.Date;
@ManagedBean
public class CalendarBacking {
private Date dateOfBirth;
public Date getDateOfBirth() {
return dateOfBirth;
}
public void setDateOfBirth(Date dateOfBirth) {
this.dateOfBirth = dateOfBirth;
}
public void submit() {
System.out.printf("Submitted");
}
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
Detecting an "invalid date" Date instance in JavaScript
Passing any value that the Date constructor can convert to a valid Date object is treated as a valid date, e.g. isValidDate(0) and...
Read more ><input type="date"> - HTML: HyperText Markup Language
elements of type="date" create input fields that let the user enter a date, either with a textbox that validates the input or a...
Read more >Date Field Popup issues | Adobe Acrobat
For a form with a Date field, when the Calendar popup is displayed ... popup errors telling you the data the field let...
Read more >Common Problems with Google Calendar - Zapier
This may happen if the start and end time/date are invalid. Events created with an invalid start or end date will be created...
Read more >Guides - Moment.js
The guides area is designed to help developers learn to better interact with the date and ... but rather increments or decrements the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@melloware Thanks so much for confirming that it’s fixed in Elite 8.0.2 and 9.0. Is there a tentative release schedule for 9.0?
Well i don’t work for PrimeTek but base on the last 3 releases they are about once a year. 8.0 was released in March so I would guess 9.0 sometime early 2021 if their pattern holds…