jquery DateTimePicker validation for dd/mm/yy is not working correctly - datetimepicker

I'm new in jquery. In my MVC project most of the validations are done in jquery. All are working fine expect this date field. Let me describe my problem.
I have a date textbox, which is attached to datetimepicker. My code is below.
$("#DateTimeTextBox").datetimepicker({
dateFormat: 'dd/mm/yy',
timeFormat: 'hh:mm'
});
For validating this field i'm using this code
'DateTimeTextBox': {
required: true,
date: true
},
Here if we give the date format is 'mm/dd/yy' for datetimepicker the validation is showing correct. if we give the date format like this 'dd/mm/yy', always show the validation error message "Please enter a valid date". But I'm giving the correct date like "25/11/2012".
Is there anywhere need to set the date format for validation.
Thanks
Bobbin Paulose

The additional-methods.js file is bundled with jquery validate and has a bunch of useful methods including a method 'dateITA' that you can use to validate a date in the format dd/mm/yyy. Download the latest query validate code here.
https://github.com/jzaefferer/jquery-validation
Add a reference to additional-methods.js in your page, and use the rule 'dateITA' instead of 'date'.

Related

Posting localized Date formats in ASP.net core with bootstrap datepicker

We currently use bootstrap datepicker in our asp.net core application to select dates that essentially are localized. So I've added all the locale files for the specific languages and these all work fine until I issue a form submit.
For instance say the locale is es for spanish with a date like 27 OKT 2021 I get an error RE:
The date is not a valid date
How can I convert this back to say en-GB on post so that my model stays valid ?
see the settings for my datepicker in the cshtml view below:
$(".datepicker").datepicker({
//format: "dd M yyyy",
language: "#CultureInfo.CurrentUICulture.ToString()",
weekStart: 1,
maxViewMode: 2,
todayHighlight: true,
startDate: startDate,
daysOfWeekDisabled: [],
showOnfocus: true,
autoClose: true,
orientation: "bottom"
});
I also have a date format set in the cshtml view like so :
asp-format="{0:dd MMM yyyy}
A best practice for working with dates and times is to use ISO 8601 formats, which are standard and universal. This way you avoid localization problems and only store unambiguous dates and times.
For dates, the format is:
YYYY-MM-DD
In JavaScript you can convert a Date object to ISO format using toISOString(). See docs.

How to convert date (1991-08-23T00:00:00) which is captured in response and then convert this format (08-23-1991) in vugen?

I am working on a script where I need to submit a form and do some authentication during the steps. I am using LoadRunner Vugen for scripting. For one of the request's response I can see birthdate is coming like below:
"suffixName": ""
"birthDate": "1991-08-23T00:00:00",
"agencyName": ""
In another later request I can see in jason body the same date is used like below
"Body={\agentSuffix":null,"agentFirstName":"XYZ","agentLastName":"WSD","agentBirthDate":"08-23-1991" and so on with additional body.
I am able to capture the date from response by using web_reg_save_param_ex. But now how do I convert the value so that I can use it in next jason body in a custom request. I just need help to capture it.
Captured value: 1991-08-23T00:00:00
Expected value: 08/23/1991
Thanks in advance
Correlate for the string
Use your programming skills in the language of your virtual user to transform transform the string into a new string. Your test code might be C, JavaScript, Java, ... so use language-appropriate string conversion functions.
Hints
"LB=birthDate":"", "RB=T00:00:00"
Conside the loop and what this means for the use of substring and sprintf();
for (counter=0;counter<=strlen(lr_eval_string(MyCorrelatedVarName));counter++)
{ lr_message("%s",&lr_eval_string(MyCorrelatedVarName)[counter]); }

SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect date value: '05/20/2020'

I'm making an app with laravel, this features a calendar. I'm using "fullcalendar" which is very restricting on date format and AFAIK only accepts 'yyyy/mm/dd'. I'm using the jQuery datepicker and have edited the formatting to make it work. That all works fine and on the insert for a long time I would never get this error, however suddenly it's started giving me this error after days of not having it. I really don't understand. Unless there's a way to change fullcalendar formatting to match the accepted formatting for SQL, which has not affected my app since now, then I'd love to hear it.
(error: QLSTATE[22007]: Invalid datetime format: 1292 Incorrect date value: '05/14/2020' for column)
Thanks.
fixed it, my formatter was broken

RSA Archer user cannot specify a date in the future / past

Has anyone any good patterns for RSA Archer validation which prevents a user from saving the record when a given date specified is in the future (or past)?
Currently I am catching this using calculated fields after the data has been saved, in a data exceptions report. But ideally I would like to catch this early prior to the user saving the record.
I would suggest that you use custom object in this case.
So remove the basic onclick attribute of the SAVE and APPLY button.
In your custom object, check if the entered date matches the system date (or the time-zone you need). Set a flag. Based on the flag value, you can call the actual function call of the SAVE or APPLY button.
Hope that helps!
Alex,Tanveer is correct. You have to use a Custom Object with embedded JavaScript code to implement described functionality.
You will need to create a function that will validate the value entered by the end user and either accept it or make user correct himself.
Now, you have two options how to do it:
1. You can attach your validation function to the Save and Apply buttons as Tanveer described. I have shared a similar code in the following question before. You can review it here: LINK
2. You can attach your validation function to the element you plan to validate directly. So when user is done with given input element and input element loses focus your function will be called. Here is a sample code with jQuery:
$('#elementid').blur(function() {
// validate entered value here
// if required show a pop-up message
WarningAlert(msg, title);
});
Good luck!

fnServerParams isn't working for me

I need to send custom filters to my server side processing for dataTables.net
I have a drop down which contains dates, after the user has seleted a date, then the tables need to reflect the option they have selected. I can't for the life of me work out why this isn't sending anything:
"fnServerParams": function (aoData) {
aoData.push({"name": "iArchiveYears", "value": $("ddYears option:selected").text()})
when I look in firebug, iArchiveYears in there, but empty.
Even hardcoding a value in here instead of the drop down value doesn't work.
Any advice most welcome.
Use $("#ddYears option:selected")
Instead of
$("ddYears option:selected").
# missing.