only submit server side request when date in date range is in valid format - yadcf

I am using YADCF with date range filter. I am using the jQuery-ui datepicker type. Data is returned to the datatable from AJAX requests (serverSide is set in the datatables config).
This works fine as long as the user selects a valid date from the UI box. However, the user can also enter free text into the box (e.g '20') and when this happens the server side raises an exception and returns error 400. This is ok but the ideal solution would be for the date format to be validated client-side, and the AJAX request is only sent when there is a valid date in the range box.
Is it possible to configure yadcf / datatables to only submit AJAX requests when there is a valid date?
yadcf.init(table, [
{
column_number: 0,
filter_type: 'range_date',
datepicker_type: 'jquery-ui',
date_format: 'yyyy-mm-dd',
filter_delay: 500,
filter_container_id: 'timestamp_range_picker'
}
]

You should probably fix this issue at the source, which is your input box. Set it as a date type and then there will be no chance of incorrect entry.
<input type="date" />

Related

How to insert validation in datepicker interactive report in apex5.0

I have one field :P2_DATE, datepicker on an interactive report in apex5.0.
First Question:
How can i create validation thru:
1. A dynamic action
2. A validation process
that gives an error msg: 'Date should not be greater than system date'
when user choose from datepicker.
Second Question:
How to show only today's date in the date picker and disable others dates.
Pls provide steps-by-steps instruction if possible...thxs!!
Add Validation
Set type to PL/SQL Expression and put:
to_date(:P2_DATE,'DD-MM-YYYY') = to_date(sysdate,'DD-MM-YYYY')
You can see this Answer:jQuery Date Picker - disable past dates for disable dates in datepicker but you already have control over date by validation.
Another way is to create custom datepicker from external plugin.

How to change the configuration/input options of a Kendo NumericTextBox after creation

In Kendo, is it possible to change the configutation options of a Kendo NumericTextBox after it has been created?
I need a field to accept either a currency or a percentage, based on options set elsewhere. For simplicity, the below code shows the basic case of trying to change the placeholder, but I'll need to change the format, min, and max as well.
In my code, the original NumericTextBox is defined by Kendo MVC (but it could be changed to Kendo UI if there's a solution there).
Here is code in my ASP MVC view file:
<span>
#(Html.Kendo().NumericTextBoxFor(m => m.fieldName)
.Min(0)
.Spinners(false)
.Decimals(2)
.Format("c2")
.Placeholder("Enter amount")
.HtmlAttributes(new { #class = "input-amount", id = "kendo_ntb" })
)
</span>
To valiate I am accessing the object for the correct Kendo NumericTextBox, I run the below code (reference - How can I refresh value kendo numerictextbox?). As expected, it changes the value displayed in the field to "$999.00"
$("#kendo_ntb").data("kendoNumericTextBox").value("999");
I can access and change the options object as well; however, there is no change in how the NumericTextBox displays. In the Chrome console, I entered:
$("#kendo_ntb").data("kendoNumericTextBox").options["placeholder"] = "Enter Percentage"
$("#kendo_ntb").data("kendoNumericTextBox").options["placeholder"]
This returns "Enter Percentage" but placeholder displayed in the browser still reads "Enter Amount".
I was trying to following this example (How can I refresh value kendo numerictextbox?).
I tried the solution here with the same result: the options object change, but the browser display does not. No error is returned, but after running the below command, clicking on the form element no longer lets you enter a value.
$("#kendo_ntb").data("kendoNumericTextBox").setOptions({format: "#.#", decimals: 1, placeholder: "change please" });

Formatting date in domForm.toJson in dojo

In my Web Application i have changed my dijit/form/DateTextBox date format using constraints="{datePattern:'MM/dd/yyyy'}" attribute,
But when i call the form containing the dijit/form/DateTextBox using domForm.toJson the format is changed to yyyy/dd/MM
why?
How to solve it
Dijit/Form/DateTextBox is a dojo/widget not dom.
domForm.toJson access Dom's value not Dijit widget's get('value') function which gives you a formatted output as you expect.
To get correct value - Use Dijit/Form and then use form.get("value")
Dijit Form

Disable Validation in Dojo datetextbox

Is there a way to turn off or disable client site validation in dojo's form widget datetextbox. I would like users to be able to type the date in if they want and support most common date formats
Your question is not quite clear at "disable client site validation". If I understand you correct, you are asking to be able input any value manually and also be able to use date dropdown pickup.
There is an _isInvalidDate method you can try to overwrite like:
new DateTextBox({
value: "31-DEC-2009",
name: "oracle",
_isInvalidDate: function(){return false;}
onChange: function(v){ }
}, "oracle");
Since this is an internal(private) method, it is not suggested but may work.
There is another method you can feel free to overwrite to use your own validation Regexp in constrints:
validator: function(/*anything*/ value, /*__Constraints*/ constraints){

FormBlock Server Control in Ektron

I am working in Ektron 8.6.
I have a FormBlock Server Control in my Template Page,It is having a DefualutFormID of a valid HTML form from workarea.The form in the workarea have got few form fields and their corresponding values.
While the template page is rendering I need to GET those form field values and re-set them with some other values.
In which Page –Cycle event I should do this coding?
I tried this code in Pre-Render Event,but I am unable to GET the value there,but I am able to set a value.
I tried SaveStateComplete event as well,no luck.
String s=FormBlock1.Fields["FirstName"].Value;
If(s=”some text”)
{
// Re-set as some other vale.
FormBlock1.Fields["FirstName"].Value=”Some other value”;
}
In which event I can write this piece of code?
Page_Load works fine for changing the value of a form field. The default behavior is for the Ektron server controls to load their data during Page_Init.
The real problem is how to get the default value. I tried every possible way I could find to get at the data defining an Ektron form (more specifically, a field's default value), and here's what I came up with. I'll admit, this is a bit of a hack, but it works.
var xml = XElement.Parse("<ekForm>" + cmsFormBlock.EkItem.Html + "</ekForm>");
var inputField = xml.Descendants("input").FirstOrDefault(i => i.Attribute("id").Value == "SampleTextField");
string defaultValue = inputField.Attribute("value").Value;
if (defaultValue == "The default value for this field is 42")
{
// do stuff here...
}
My FormBlock server control is defined on the ASPX side, nothing fancy:
<CMS:FormBlock runat="server" ID="cmsFormBlock" DynamicParameter="ekfrm"/>
And, of course, XElement requires the following using statement:
using System.Xml.Linq;
So basically, I wrap the HTML with a single root element so that it becomes valid XML. Ektron is pretty good about requiring content to be XHTML, so this should work. Naturally, this should be tested on a more complicated form before using this in production. I'd also recommend a healthy dose of defensive programming -- null checks, try/catch, etc.
Once it is parsed as XML, you can get the value property of the form field by getting the value attribute. For my sample form that I set up, the following was part of the form's HTML (EkItem.Html):
<input type="text" value="The default value for this field is 42" class="design_textfield" size="24" title="Sample Text Field" ektdesignns_name="SampleTextField" ektdesignns_caption="Sample Text Field" id="SampleTextField" ektdesignns_nodetype="element" name="SampleTextField" />