Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Added Step attribute to number input type #2795

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,11 @@ public static string TimeInputTemplate(IHtmlHelper htmlHelper)

public static string NumberInputTemplate(IHtmlHelper htmlHelper)
{
return GenerateTextBox(htmlHelper, inputType: "number");
var htmlAttributes =
CreateHtmlAttributes(htmlHelper, className: "text-box single-line", inputType: "number");
htmlAttributes["step"] = "any";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this was needed for only decimal-enabled types: float, double, and decimal. For integral types there's no step needed, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plus, the code here now looks more "complicated" because it seems to slightly duplicate some existing logic...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. I was investigating #2780 and it is possible that we might not even need this change based on what we decide for that scenario.


return GenerateTextBox(htmlHelper, htmlHelper.ViewData.TemplateInfo.FormattedModelValue, htmlAttributes);
}

public static string FileInputTemplate([NotNull] IHtmlHelper htmlHelper)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="editor-label"><label for="Vin">Vin</label></div>
<div class="editor-field"><input class="input-validation-error text-box single-line" data-val="true" data-val-length="The field Vin must be a string with a maximum length of 8." data-val-length-max="8" data-val-required="The Vin field is required." id="Vin" name="Vin" type="text" value="8765432112345678" /> <span class="field-validation-error" data-valmsg-for="Vin" data-valmsg-replace="true">The field Vin must be a string with a maximum length of 8.</span></div>
<div class="editor-label"><label for="Year">Year</label></div>
<div class="editor-field"><input class="input-validation-error text-box single-line" data-val="true" data-val-range="The field Year must be between 1980 and 2034." data-val-range-max="2034" data-val-range-min="1980" data-val-required="The Year field is required." id="Year" name="Year" type="number" value="1979" /> <span class="field-validation-error" data-valmsg-for="Year" data-valmsg-replace="true">The field Year must be between 1980 and 2034.</span></div>
<div class="editor-field"><input class="input-validation-error text-box single-line" data-val="true" data-val-range="The field Year must be between 1980 and 2034." data-val-range-max="2034" data-val-range-min="1980" data-val-required="The Year field is required." id="Year" name="Year" step="any" type="number" value="1979" /> <span class="field-validation-error" data-valmsg-for="Year" data-valmsg-replace="true">The field Year must be between 1980 and 2034.</span></div>
<div class="editor-label"><label for="LastUpdatedTrackingId">LastUpdatedTrackingId</label></div>
<div class="editor-field"><input class="text-box single-line" id="LastUpdatedTrackingId" name="LastUpdatedTrackingId" type="text" value="" /> <span class="field-validation-valid" data-valmsg-for="LastUpdatedTrackingId" data-valmsg-replace="true"></span></div>
<div class="editor-label">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="editor-label"><label for="Vin">Vin</label></div>
<div class="editor-field"><input class="text-box single-line" data-val="true" data-val-length="The field Vin must be a string with a maximum length of 8." data-val-length-max="8" data-val-required="The Vin field is required." id="Vin" name="Vin" type="text" value="87654321" /> <span class="field-validation-valid" data-valmsg-for="Vin" data-valmsg-replace="true"></span></div>
<div class="editor-label"><label for="Year">Year</label></div>
<div class="editor-field"><input class="text-box single-line" data-val="true" data-val-range="The field Year must be between 1980 and 2034." data-val-range-max="2034" data-val-range-min="1980" data-val-required="The Year field is required." id="Year" name="Year" type="number" value="2013" /> <span class="field-validation-valid" data-valmsg-for="Year" data-valmsg-replace="true"></span></div>
<div class="editor-field"><input class="text-box single-line" data-val="true" data-val-range="The field Year must be between 1980 and 2034." data-val-range-max="2034" data-val-range-min="1980" data-val-required="The Year field is required." id="Year" name="Year" step="any" type="number" value="2013" /> <span class="field-validation-valid" data-valmsg-for="Year" data-valmsg-replace="true"></span></div>
<div class="editor-label"><label for="LastUpdatedTrackingId">LastUpdatedTrackingId</label></div>
<div class="editor-field"><input class="text-box single-line" id="LastUpdatedTrackingId" name="LastUpdatedTrackingId" type="text" value="" /> <span class="field-validation-valid" data-valmsg-for="LastUpdatedTrackingId" data-valmsg-replace="true"></span></div>
<div class="editor-label">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<span class="field-validation-error" data-valmsg-for="Vehicle.Vin" data-valmsg-replace="true">The field Vin must be a string with a maximum length of 8.</span>
</fieldset>
<fieldset>
<input class="input-validation-error text-box single-line" data-val="true" data-val-range="The field Year must be between 1980 and 2034." data-val-range-max="2034" data-val-range-min="1980" data-val-required="The Year field is required." id="Vehicle_Year" name="Vehicle.Year" type="number" value="9001" />
<input class="input-validation-error text-box single-line" data-val="true" data-val-range="The field Year must be between 1980 and 2034." data-val-range-max="2034" data-val-range-min="1980" data-val-required="The Year field is required." id="Vehicle_Year" name="Vehicle.Year" step="any" type="number" value="9001" />
<span class="field-validation-error" data-valmsg-for="Vehicle.Year" data-valmsg-replace="true">The field Year must be between 1980 and 2034.</span>
</fieldset>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<span class="field-validation-valid" data-valmsg-for="Vehicle.Vin" data-valmsg-replace="true"></span>
</fieldset>
<fieldset>
<input class="text-box single-line" data-val="true" data-val-range="The field Year must be between 1980 and 2034." data-val-range-max="2034" data-val-range-min="1980" data-val-required="The Year field is required." id="Vehicle_Year" name="Vehicle.Year" type="number" value="2013" />
<input class="text-box single-line" data-val="true" data-val-range="The field Year must be between 1980 and 2034." data-val-range-max="2034" data-val-range-min="1980" data-val-required="The Year field is required." id="Vehicle_Year" name="Vehicle.Year" step="any" type="number" value="2013" />
<span class="field-validation-valid" data-valmsg-for="Vehicle.Year" data-valmsg-replace="true"></span>
</fieldset>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h4>Person</h4>
<div class="form-group">
<label class="control-label col-md-2" for="Id">Id</label>
<div class="col-md-10">
<input class="form-control text-box single-line" data-val="true" data-val-required="The Id field is required." id="Id" name="Id" type="number" value="" />
<input class="form-control text-box single-line" data-val="true" data-val-required="The Id field is required." id="Id" name="Id" step="any" type="number" value="" />
<span class="field-validation-valid text-danger" data-valmsg-for="Id" data-valmsg-replace="true"></span>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h4>Person</h4>
<div class="form-group">
<label class="control-label col-md-2" for="Id">Id</label>
<div class="col-md-10">
<input class="form-control text-box single-line" data-val="true" data-val-required="The Id field is required." id="Id" name="Id" type="number" value="" />
<input class="form-control text-box single-line" data-val="true" data-val-required="The Id field is required." id="Id" name="Id" step="any" type="number" value="" />
<span class="field-validation-valid text-danger" data-valmsg-for="Id" data-valmsg-replace="true"></span>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,26 @@ public static TheoryData<string, string> TemplateNameData
{ "DATETIME-LOCAL", "__TextBox__ class='text-box single-line' type='datetime-local'" },
{ "Time", "__TextBox__ class='text-box single-line' type='time'" },
{ "time", "__TextBox__ class='text-box single-line' type='time'" },
{ "Byte", "__TextBox__ class='text-box single-line' type='number'" },
{ "BYTE", "__TextBox__ class='text-box single-line' type='number'" },
{ "SByte", "__TextBox__ class='text-box single-line' type='number'" },
{ "sbyte", "__TextBox__ class='text-box single-line' type='number'" },
{ "Int16", "__TextBox__ class='text-box single-line' type='number'" },
{ "INT16", "__TextBox__ class='text-box single-line' type='number'" },
{ "UInt16", "__TextBox__ class='text-box single-line' type='number'" },
{ "uint16", "__TextBox__ class='text-box single-line' type='number'" },
{ "Int32", "__TextBox__ class='text-box single-line' type='number'" },
{ "INT32", "__TextBox__ class='text-box single-line' type='number'" },
{ "UInt32", "__TextBox__ class='text-box single-line' type='number'" },
{ "uint32", "__TextBox__ class='text-box single-line' type='number'" },
{ "Int64", "__TextBox__ class='text-box single-line' type='number'" },
{ "INT64", "__TextBox__ class='text-box single-line' type='number'" },
{ "UInt64", "__TextBox__ class='text-box single-line' type='number'" },
{ "uint64", "__TextBox__ class='text-box single-line' type='number'" },
{ "Single", "__TextBox__ class='text-box single-line' type='number'" },
{ "SINGLE", "__TextBox__ class='text-box single-line' type='number'" },
{ "Double", "__TextBox__ class='text-box single-line' type='number'" },
{ "double", "__TextBox__ class='text-box single-line' type='number'" },
{ "Byte", "__TextBox__ class='text-box single-line' type='number' step='any'" },
{ "BYTE", "__TextBox__ class='text-box single-line' type='number' step='any'" },
{ "SByte", "__TextBox__ class='text-box single-line' type='number' step='any'" },
{ "sbyte", "__TextBox__ class='text-box single-line' type='number' step='any'" },
{ "Int16", "__TextBox__ class='text-box single-line' type='number' step='any'" },
{ "INT16", "__TextBox__ class='text-box single-line' type='number' step='any'" },
{ "UInt16", "__TextBox__ class='text-box single-line' type='number' step='any'" },
{ "uint16", "__TextBox__ class='text-box single-line' type='number' step='any'" },
{ "Int32", "__TextBox__ class='text-box single-line' type='number' step='any'" },
{ "INT32", "__TextBox__ class='text-box single-line' type='number' step='any'" },
{ "UInt32", "__TextBox__ class='text-box single-line' type='number' step='any'" },
{ "uint32", "__TextBox__ class='text-box single-line' type='number' step='any'" },
{ "Int64", "__TextBox__ class='text-box single-line' type='number' step='any'" },
{ "INT64", "__TextBox__ class='text-box single-line' type='number' step='any'" },
{ "UInt64", "__TextBox__ class='text-box single-line' type='number' step='any'" },
{ "uint64", "__TextBox__ class='text-box single-line' type='number' step='any'" },
{ "Single", "__TextBox__ class='text-box single-line' type='number' step='any'" },
{ "SINGLE", "__TextBox__ class='text-box single-line' type='number' step='any'" },
{ "Double", "__TextBox__ class='text-box single-line' type='number' step='any'" },
{ "double", "__TextBox__ class='text-box single-line' type='number' step='any'" },
{ "Boolean", "__CheckBox__ class='check-box'" }, // Not tri-state b/c string is not a Nullable type.
{ "BOOLEAN", "__CheckBox__ class='check-box'" },
{ "Decimal", "__TextBox__ class='text-box single-line'" },
Expand Down