Skip to main content

All Questions

Filter by
Sorted by
Tagged with
0 votes
0 answers
29 views

is there a builtin date function that will give an error on an non-existing date? [duplicate]

I'm new to javascript. I'm trying to validate a date and find that the code below, when given feb 31 returns mar 2. Why is it "fixing" the date instead of returning an error? Is there not a ...
4mla1fn's user avatar
  • 303
1 vote
2 answers
131 views

new Date() validation of string with number

When inputing string with number the new Date() is missbehaving, is there another way how to achieve this without regex? let string = 'some string 1'; let invalid = new Date(string); it is still ...
Dzi's user avatar
  • 11
3 votes
2 answers
3k views

How to validate a date string using date-fns

I'm trying to validate a user input for a datetime using date-fns: import { isDate, isValid } from 'date-fns'; console.log('DATE:', stringVal); console.log('IS_DATE:', isDate(new Date(stringVal))); ...
dokgu's user avatar
  • 6,100
0 votes
0 answers
368 views

how to allow date format(DD-MM-YYYY) in the text field using javascript

Field is the input text not date field and it should allow only DD-MM-YYYY format. DD(1 to 31), MM(1-12) and YYYY(0001-9999). each data character should allow only "-". Step 1 : First two ...
KVC's user avatar
  • 23
0 votes
0 answers
2k views

Three dropdown date picker with a today button/choice and be able to set a not before or after alert trigger or restriction

I am looking to create a date picker with three separate, movable dropdowns, or other method, for MM DD YYYY. I would like them to be tied together with a way to choose todays date or even set that ...
Bandersnatch79's user avatar
1 vote
2 answers
58 views

JavaScript validation for date

I want to validate a date field where only last 12 months or 15 months accepted from today’s date as well for future date from today’s date any JavaScript code for this condition I used this logic var ...
Yuvraj Sawant's user avatar
0 votes
2 answers
730 views

Compare dates of an array using moment or dayjs library in javascript

I need to compare the date values of an array. I will always get two dates values in array. If date range is not in between 5 years need to display error message. filterAry = [ {type: 'date', name: '...
user1881845's user avatar
0 votes
1 answer
714 views

Validating Year in a date using JavaScript

I want to validate a person's date of birth and I am stuck trying to figure out how to go about checking if the YEAR of birth is valid using the ISO date format like this yyyy-mm-dd. I want to check ...
PalesaDev's user avatar
0 votes
4 answers
812 views

How to enable/validate date input only from current date to 50 years before in Moment.js?

I am using moment.js. I want to restrict the user son that he can only select a date which is from current date to 50 years before. In short, i just want that user's date of birth cannot be more than ...
Anshul's user avatar
  • 81
0 votes
0 answers
89 views

Date validation passes for some xss vectors

I am writing a test for a validator function which checks if a value passed is actually an instance of Date object or not. It returns either true or false. So if I pass a simple date, it passes as ...
Zak's user avatar
  • 940
0 votes
1 answer
106 views

How to check if a week arrangement is part of the month

I would like to be able to validate in an arrangement that brings me the week, if it is part of the month I pass a start_date to my function, then check if that date is part of a week that starts on ...
Izlia's user avatar
  • 372
0 votes
0 answers
64 views

Why is second date not giving me a value?

<script type="text/javascript"> function validatedates(form) { var x = new Date(form.post_at.value); var y = new Date(form.post_at_to_date.value); if (isNaN(+x) > isNaN(+y)...
AmbientGuitar's user avatar
1 vote
0 answers
223 views

Javascript - date input in Safari - Validation: 31 of February Year

How can I validate the date of 31/02/any year in Safari? In Chrome or Firefox, it can be validated by the attribute validity.badInput but in Safari is not working. Let's suppose I have a date field in ...
Vlad Pana's user avatar
0 votes
2 answers
608 views

Restrict picking minimum and maximum date with vanilla javascript for hotel reservation

I have a form for hotel reservation. I just need to validate the checkin date and the checkout date, don‘t look for a whole booking engine either. I have 2 input date fields, one for CHECKIN, the ...
limakid's user avatar
  • 81
0 votes
1 answer
648 views

How to disable/restrict user to select future and current date in bootstrap datepicker?

Problem Statement:- I am using bootstrap datepicker in React JS. I have used type="date" for the date of birth and i do not want user to be able to select current or future dates. How can i ...
user avatar

15 30 50 per page
1
2 3 4 5
16