Skip to content

Commit 0bc6dce

Browse files
authored
Merge pull request #496 from bpa-solutions/master
Minutes and Seconds validation
2 parents 591deea + 22300a0 commit 0bc6dce

File tree

5 files changed

+178
-106
lines changed

5 files changed

+178
-106
lines changed

package-lock.json

Lines changed: 150 additions & 102 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/controls/dateTimePicker/MinutesComponent.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as strings from 'ControlStrings';
12
import * as React from 'react';
23
import { ITimeComponentProps } from './ITimeComponentProps';
34
import { MaskedTextField } from 'office-ui-fabric-react/lib/TextField';
@@ -46,8 +47,17 @@ export default class MinutesComponent extends React.Component<ITimeComponentProp
4647
label=""
4748
value={value ? TimeHelper.suffixZero(value.toString()) : "00"}
4849
onGetErrorMessage={(val) => {
49-
onChange(val);
50-
return "";
50+
let message = "";
51+
const minutes: number = parseInt(val);
52+
if (isNaN(minutes)) {
53+
message = strings.DateTimePickerMinuteValueInvalid;
54+
}
55+
56+
if (!message) {
57+
onChange(val);
58+
}
59+
60+
return message;
5161
}}
5262
mask="59"
5363
maskFormat={{

src/controls/dateTimePicker/SecondsComponent.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as strings from 'ControlStrings';
12
import * as React from 'react';
23
import { ITimeComponentProps } from './ITimeComponentProps';
34
import { MaskedTextField } from 'office-ui-fabric-react/lib/TextField';
@@ -46,8 +47,17 @@ export default class SecondsComponent extends React.Component<ITimeComponentProp
4647
label=""
4748
value={value ? TimeHelper.suffixZero(value.toString()) : "00"}
4849
onGetErrorMessage={(val) => {
49-
onChange(val);
50-
return "";
50+
let message = "";
51+
const seconds: number = parseInt(val);
52+
if (isNaN(seconds)) {
53+
message = strings.DateTimePickerSecondValueInvalid;
54+
}
55+
56+
if (!message) {
57+
onChange(val);
58+
}
59+
60+
return message;
5161
}}
5262
mask="59"
5363
maskFormat={{

0 commit comments

Comments
 (0)