field validation
I have a text field that I would like validate the min and max values for but it is throwing the error "Cannot convert from string". How do I specify the min and max values?
<sitefinity:TextField ID="subscriberLimit" runat="server" DisplayMode="Write" Title='<%$Resources:CampaignsResources, SubscriberLimit %>' Description='<%$Resources:CampaignsResources, SubscriberLimitDescription %>' WrapperTag="Li"> <ValidatorDefinition Required="false" MessageCssClass="sfError" ExpectedFormat="Integer" MinValue="1" MaxValue="99999" /> </sitefinity:TextField>
<sitefinity:DateField ID="startDate" runat="server" DisplayMode="Write" Title='<%$Resources:CampaignsResources, StartDate %>' Description='<%$Resources:CampaignsResources, StartDateDescription %>' WrapperTag="Li" DataFormat="dd/MM/yyyy h:mm:ss"> <ValidatorDefinition Required="true" MessageCssClass="sfError" /> </sitefinity:DateField>
Hello Brian Crosby,
From the error that you are receiving I assume that you are using the validation on the server. If this is the case I have to inform you that the default Validator doesn't support min/max validating of field controls that work with string values even if you have set the expected format to be Integer. Could you provide more info on your usage scenario so that I can think of a suitable workaround. The information I need is where are you using those field controls how do you validate them etc.
Kind regards,Hi Brian Crosby,
About the DateField you can take a look at the following forum thread:
http://www.sitefinity.com/devnet/forums/sitefinity-4-x/general-discussions/event-time-picker---12-hour-format.aspx
It describes how can you set the date picker to a 12 hour format. The property you need is located here:
...
this._datePicker = jQuery("#" + this._datePickerId).datetimepicker(
dateFormat: "mm/dd/yy",
timeFormat: "hh:mm:ss",
hourGrid: 4,
minuteGrid: 10,
beforeShow: popupOpeningDelegate,
onClose: popupClosedDelegate,
showOn: "focus",
ampm: true
);
...
Hi Brian Crosby,
The reason behind this behaviour is that the regex check is applied even if the string is empty. This is a bug which is fixed and will be available in the next SP release.
Since you have already developed such regex the fastest workaround would be to modify it to allow empty strings like this:
"^(<your custom regex expression>])0,1$"
Hello Brian Crosby,
I have left an unnecessary character in the regex example. The correct one is this:
"^(<your custom regex expression>)0,1$"