There is no client side date validator in the default themes. I added a basic one in the xhtml theme for use with the datetimepicker; it has a hardcoded date format though (dd/MM/yyyy).
To add it, open your xhtml theme's form-close-validate.ftl file, and as the last option add the following lines: <#elseif validator.validatorType = "date"> if (continueValidation && field.value != null && field.value != "" && field.value.replace(/^\s+|\s+$/g,"").length != 0) { var datePicker = dojo.widget.byId(field.parentNode.id); var value = datePicker.getDate(); <#if validator.min?exists> var minValue = dojo.date.parse("${validator.min?date}", {datePattern: 'dd/MM/yyyy'}); <#else> var minValue = null; </#if> <#if validator.max?exists> var maxValue = dojo.date.parse("${validator.max?date}", {datePattern: 'dd/MM/yyyy'});; <#else> var maxValue = null; </#if> if ((minValue != null && value < minValue) || (maxValue != null && value > maxValue)) { addError(field, error); errors = true; <#if validator.shortCircuit>continueValidation = false;</#if> } } </#if> 2008/9/11 Kawczynski, David <[EMAIL PROTECTED]>: > I am using the datetimepicker on a form with client-side validation > enabled. > Form submissions with a blank datetime field should result in validation > > being run against that field. This is not the case -- this field is > only > validated on the server. No other form field uses the dojo, and they > are all > validated on the client-sided correctly. What do I have to do so the > datetimepicker field receives client-sided validation like the other > fields? > (I'm using struts 2.1.2 with xwork 2.1.1) > > Thanks in advance, > -dave > > > > ======================================================================= > ======================================================================= > ==THE struts.xml: > > <!DOCTYPE struts PUBLIC > "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" > "http://struts.apache.org/dtds/struts-2.0.dtd"> > > <struts> > <include file="struts-default.xml"/> > <constant name="struts.action.extension" value="action" /> > <constant name="struts.devMode" value="true" /> > <constant name="struts.multipart.maxSize" value="2097152" /> > <constant name="struts.configuration.xml.reload" value="true" /> > > <package name="siterequest" > namespace="/admin/siterequest" > extends="struts-default"> > <default-interceptor-ref name="defaultStack"/> > <action name="save" > method="save" > class="siterequest.SiteRequestAction"> > <result>/admin/siterequest/request_form_thanks.jsp</result> > <result name="input">/admin/siterequest/request_form.jsp</result> > <result > name="failure">/admin/siterequest/request_form.jsp</result> > </action> > </package> > > </struts> > > > > ======================================================================= > ======================================================================= > ==THE SiteRequestAction-save-validation.xml: > > <?xml version="1.0" encoding="UTF-8"?> > <!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator > 1.0.2//EN" > > "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> > <validators> > <field name="siteRequest.isid"> > <field-validator type="requiredstring"> > <param name="trim">true</param> > <message>"Submitter ISID" is required</message> > </field-validator> > <field-validator type="stringlength"> > <param name="maxLength">8</param> > <message>"Submitter ISID" must be 8 characters or less</message> > </field-validator> > </field> > <field name="siteRequest.businessArea"> > <field-validator type="requiredstring"> > <param name="trim">true</param> > <message>"Business Area" is required</message> > </field-validator> > </field> > <field name="siteRequest.projectTitle"> > <field-validator type="requiredstring"> > <param name="trim">true</param> > <message>"Project Title" is required</message> > </field-validator> > <field-validator type="stringlength"> > <param name="maxLength">200</param> > <message>"Project Title" must be 200 characters or less</message> > </field-validator> > </field> > <field name="siteRequest.description"> > <field-validator type="requiredstring"> > <param name="trim">true</param> > <message>"Description" is required</message> > </field-validator> > <field-validator type="stringlength"> > <param name="maxLength">2000</param> > <message>"Description" must be 2000 characters or less</message> > </field-validator> > </field> > <field name="siteRequest.siteName"> > <field-validator type="requiredstring"> > <param name="trim">true</param> > <message>"Site Name" is required</message> > </field-validator> > <field-validator type="stringlength"> > <param name="maxLength">200</param> > <message>"Site Name" must be 200 characters or less</message> > </field-validator> > </field> > <field name="siteRequest.issueType"> > <field-validator type="requiredstring"> > <param name="trim">true</param> > <message>"Issue Type" is required</message> > </field-validator> > </field> > <field name="siteRequest.releaseDate"> > <field-validator type="required"> > <message>"Desired Release Date" is required.</message> > </field-validator> > <field-validator type="date"> > <param name="min">08/01/2008</param> > <param name="max">01/01/2030</param> > <message>Invalid "Desired Release Date"</message> > </field-validator> > </field> > </validators> > > > > ======================================================================= > ======================================================================= > ==THE jsp page: > > <%@ taglib prefix="s" uri="/struts-tags" %> > <%@ taglib prefix="sx" uri="/struts-dojo-tags" %> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> > <html> > <head> > <title>Change Request Submission Form</title> > <sx:head/> > <s:head/> > <link rel="stylesheet" href="/admin/css/site-request.css" > type="text/css" /> > </head> > <body> > <div id="content"> > <h1>Change Request Submission Form</h1> > > <p>Please complete the form below to submit a request to the > Global > Solutions Delivery group. You will receive a response within 2 > business > days.</p> > > <p>Items marked with an asterisk (<span class="required">*</span>) > are > required.</p> > > <s:form action="save" > namespace="/admin/siterequest" > name="requestform" > method="post" > enctype="multipart/form-data" > theme="xhtml" > validate="true"> > <table> > <s:textfield name="siteRequest.isid" > label="Submitter ISID" > maxlength="8" > required="true" /> > <s:select name="siteRequest.businessArea" > label="Business Area" > list="businessAreaList" > required="true"/> > <s:textfield name="siteRequest.projectTitle" > label="Project Title" > maxlength="200" > required="true" /> > <s:textarea name="siteRequest.description" > label="Description" > cols="34" > rows="5" > required="true" /> > <s:textfield name="siteRequest.siteName" > label="Site Name" > maxlength="200" > required="true" /> > <s:select name="siteRequest.issueType" > label="Issue Type" > list="issueTypeList" > required="true" /> > <sx:datetimepicker name="siteRequest.releaseDate" > label="Desired Release Date" > displayFormat="MM/dd/yyyy" > required="true" /> > <s:file name="siteRequest.upload" > label="Attachment" > required="false" /> > <s:submit cssStyle="width:80px; align:left;"/> > </table> > </s:form> > </div> > > </body> > </html> > > > > ======================================================================= > ======================================================================= > ==THE action class: > > package siterequest; > import java.util.Map; > import org.apache.log4j.Logger; > import org.apache.struts2.interceptor.SessionAware; > import com.opensymphony.xwork2.ActionSupport; > import com.opensymphony.xwork2.Preparable; > > public class SiteRequestAction extends ActionSupport > implements Preparable, SessionAware { > > /** > * Performs all functionality required when saving a [EMAIL PROTECTED] > SiteRequest}. > * > * @return > * a String indicating "success" or "failure". If "failure", > * this action's [EMAIL PROTECTED] #exception} property will be > populated. > */ > public String save() { > try { > this.siteRequestFacade.save(this.siteRequest); > return "success"; > } > catch (Throwable exception) { > logger.error("Unable to save SiteRequest: ", exception); > setException(exception); > return "failure"; > } > } > > public void prepare() throws Exception { > this.siteRequestFacade = new SiteRequestFacade(); > this.siteRequest = new SiteRequest(); > this.siteRequestList = new ArrayList<SiteRequest>(); > } > > public void setSession(Map session) { > this.session = session; > } > > public SiteRequest getSiteRequest() { > return siteRequest; > } > > public void setSiteRequest(SiteRequest siteRequest) { > this.siteRequest = siteRequest; > } > > private Map session; > private SiteRequest siteRequest; > private SiteRequestFacade siteRequestFacade; > private Throwable exception; > private Logger logger = Logger.getLogger(this.getClass()); > } > > > > ======================================================================= > ======================================================================= > ==THE action form class: > > package siterequest; > import java.io.File; > import java.io.FileInputStream; > import java.io.IOException; > import java.io.InputStream; > import java.sql.Blob; > import java.sql.SQLException; > import java.util.Date; > import org.hibernate.Hibernate; > > public class SiteRequest implements java.io.Serializable { > > private static final long serialVersionUID = 1L; > private Long siteRequestId; > private String isid; > private String businessArea; > private String projectTitle; > private String description; > private String siteName; > private String issueType; > private Date releaseDate; > private String creator; > private Date creationDate; > private String updater; > private Date updateDate; > private File upload; > private String uploadFileName; > private String uploadContentType; > private Blob attachment; > > > public SiteRequest() { > } > > public String getBusinessArea() { > return businessArea; > } > > public void setBusinessArea(String businessArea) { > this.businessArea = businessArea; > } > > public Date getCreationDate() { > return creationDate; > } > > public void setCreationDate(Date creationDate) { > this.creationDate = creationDate; > } > > public String getCreator() { > return creator; > } > > public void setCreator(String creator) { > this.creator = creator; > } > > public String getDescription() { > return description; > } > > public void setDescription(String description) { > this.description = description; > } > > public String getIsid() { > return isid; > } > > public void setIsid(String isid) { > this.isid = isid; > } > > public String getIssueType() { > return issueType; > } > > public void setIssueType(String issueType) { > this.issueType = issueType; > } > > public String getProjectTitle() { > return projectTitle; > } > > public void setProjectTitle(String projectTitle) { > this.projectTitle = projectTitle; > } > > public Date getReleaseDate() { > return releaseDate; > } > > public void setReleaseDate(Date releaseDate) { > this.releaseDate = releaseDate; > } > > public String getSiteName() { > return siteName; > } > > public void setSiteName(String siteName) { > this.siteName = siteName; > } > > public Long getSiteRequestId() { > return siteRequestId; > } > > public void setSiteRequestId(Long siteRequestId) { > this.siteRequestId = siteRequestId; > } > > public Date getUpdateDate() { > return updateDate; > } > > public void setUpdateDate(Date updateDate) { > this.updateDate = updateDate; > } > > public String getUpdater() { > return updater; > } > > public void setUpdater(String updater) { > this.updater = updater; > } > > public File getUpload() { > return upload; > } > > public void setUpload(File upload) { > this.upload = upload; > } > > public String getUploadContentType() { > return uploadContentType; > } > > public void setUploadContentType(String uploadContentType) { > this.uploadContentType = uploadContentType; > } > > public String getUploadFileName() { > return uploadFileName; > } > > public void setUploadFileName(String uploadFileName) { > this.uploadFileName = uploadFileName; > } > > public Blob getAttachment() { > try { > if(this.attachment != null) { > return this.attachment; > } > else { > if(this.upload != null) { > return Hibernate.createBlob(new FileInputStream(this.upload)); > } > else return null; > } > } > catch (IOException ioException) { > ioException.printStackTrace(); > return null; > } > } > > public void setAttachment(Blob attachment) { > this.attachment = attachment; > } > > public InputStream getAttachmentStream() throws SQLException { > return (this.attachment==null ? null : > this.attachment.getBinaryStream()); > } > > public void setAttachmentStream(InputStream attachmentStream) throws > IOException { > this.attachment = Hibernate.createBlob(attachmentStream); > } > } > Notice: This e-mail message, together with any attachments, contains > information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station, > New Jersey, USA 08889), and/or its affiliates (which may be known > outside the United States as Merck Frosst, Merck Sharp & Dohme or > MSD and in Japan, as Banyu - direct contact information for affiliates is > available at http://www.merck.com/contact/contacts.html) that may be > confidential, proprietary copyrighted and/or legally privileged. It is > intended solely for the use of the individual or entity named on this > message. If you are not the intended recipient, and have received this > message in error, please notify us immediately by reply e-mail and > then delete it from your system. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]