-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
negative value for age input #1375 #1379
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -625,7 +625,14 @@ function CreatePatientForm(props) { | |
})} | ||
id="years" | ||
type="number" | ||
onChange={(e) => handleYearsChange(e, values)} | ||
min="0" // Prevent negative years | ||
onChange={(e) => { | ||
const value = Math.max(0, parseInt(e.target.value || 0)); // Ensure no negative values | ||
handleYearsChange( | ||
{ ...e, target: { ...e.target, value } }, | ||
values, | ||
); | ||
}} | ||
placeholder={intl.formatMessage({ | ||
id: "patient.information.age", | ||
})} | ||
|
@@ -637,8 +644,17 @@ function CreatePatientForm(props) { | |
name="months" | ||
labelText={intl.formatMessage({ id: "patient.age.months" })} | ||
type="number" | ||
onChange={(e) => handleMonthsChange(e, values)} | ||
id="months" | ||
min="0" // Prevent negative months | ||
max="11" // Limit months to 0–11 | ||
onChange={(e) => { | ||
let value = parseInt(e.target.value || 0); | ||
value = Math.min(11, Math.max(0, value)); // value between 0 and 11 | ||
handleMonthsChange( | ||
{ ...e, target: { ...e.target, value } }, | ||
values, | ||
); | ||
}} | ||
placeholder={intl.formatMessage({ | ||
id: "patient.information.months", | ||
})} | ||
|
@@ -649,16 +665,22 @@ function CreatePatientForm(props) { | |
value={dateOfBirthFormatter.days} | ||
name="days" | ||
type="number" | ||
onChange={(e) => handleDaysChange(e, values)} | ||
labelText={intl.formatMessage({ id: "patient.age.days" })} | ||
id="days" | ||
min="0" // Prevent negative days | ||
max="30" // Limit days to 0–30 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think you cant hard code 30 as the max days as this varies depensidn on the month There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay will change it to 31 or can make changes to code on month conditions also |
||
onChange={(e) => { | ||
let value = parseInt(e.target.value || 0); | ||
value = Math.min(30, Math.max(0, value)); //value between 0 and 30 | ||
handleDaysChange( | ||
{ ...e, target: { ...e.target, value } }, | ||
values, | ||
); | ||
}} | ||
labelText={intl.formatMessage({ id: "patient.age.days" })} | ||
placeholder={intl.formatMessage({ | ||
id: "patient.information.days", | ||
})} | ||
/> | ||
<div className="error"> | ||
<ErrorMessage name="birthDateForDisplay"></ErrorMessage> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. did you remove this error message intentionally ?? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nopes should i fix it? |
||
</div> | ||
</Column> | ||
<Column lg={16} md={8} sm={4}> | ||
{" "} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Logic is already handles
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which line, can you please explain a bit?