Skip to content

Commit

Permalink
fix bug with entering small years
Browse files Browse the repository at this point in the history
  • Loading branch information
alicewriteswrongs committed Jun 27, 2016
1 parent 5e7a3da commit a10b48c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions static/js/util/profile_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,9 @@ export function boundDateField(keySet: string[], label: string, omitDay: boolean
// store the edit value and make the formatted date undefined so it doesn't pass validation
_.set(clone, keySet, null);
} else {
let momentDate = moment(`${validatedYear}-${validatedMonth}-${validatedDay}`, ISO_8601_FORMAT);
if (!momentDate.isValid()) {
let formattedYear = _.padStart(validatedYear, 4, '0');
let momentDate = moment(`${formattedYear}-${validatedMonth}-${validatedDay}`, ISO_8601_FORMAT);
if (!momentDate.isValid() || momentDate.isBefore(moment("1800", "YYYY"))) {
// date is invalid according to moment.js so make the formatted date undefined so it
// doesn't pass validation
_.set(clone, keySet, null);
Expand Down

0 comments on commit a10b48c

Please sign in to comment.