Tips for achieving consistent outcomes on both IE and Chrome when utilizing the `min` attribute in HTML input tags

The display of input fields is inconsistent between IE (version 11) and Chrome (version 46.0.2490.71) when using the min option in the HTML input tag. In Chrome, the input fields appear extra long, while in IE they display correctly (same as when min is not used).

To observe this inconsistency, please open the HTML file in IE as jsfiddle will always show the unwanted longer input fields.

Here is a link to the sample jsfiddle: min demo

Is there a solution you can suggest to achieve consistent display on both IE and Chrome while using min in the HTML input type="number"?

HTML Code:

<html>
    <head>
        <title>CommDesk AdminPage</title>
        <meta HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function(){
                addPlusSign();
                $(".btn1").click(function(){
                    $(".expand1").toggle();
                    var btn1Text = $(".btn1").text();
                    if(btn1Text.indexOf("+") > -1){
                        var temp = btn1Text.replace(/\+|\-/ig, '-');
                        $(".btn1").text(temp);
                    } else if (btn1Text.indexOf("-") > -1){
                        var temp = btn1Text.replace(/\+|\-/ig, '+');
                        $(".btn1").text(temp);
                    }
                });
            })
            function addPlusSign(){
                if($(".expand1")){
                    var btn1Text = $(".btn1").text();
                    $(".btn1").text(btn1Text + " [+]");
                }
            }
            $(function () {
                $('.admin-form')
                //we need to save values from all inputs with class 'admin-input'
                .find(':input.admin-input')
                .each(function () {
                    //save old value in each input's data cache
                    $(this).data('oldValue', $(this).val())
                })
                .end()
                .submit(function (ev) {
                    var changed = false;
                    $(':input.admin-input', this).filter(function () {
                        if($(this).val() != $(this).data('oldValue')){
                            changed = true;
                        }
                    });
                    if($(this).hasClass('changed') && (!changed)){
                        alert("None of the thresholds were changed!");
                        ev.preventDefault()
                    }
                    if($(this).hasClass('changed') && changed){
                        var allowSubmit = window.confirm("You have set a unique threshold for one or more sub-elements below. Are you sure you want to reset them all?")
                        if (!allowSubmit)
                        ev.preventDefault()
                    }
                });
            });
            $(document).on('input', '.admin-input', function(){
                $(this).closest('form').addClass('changed');
            });
        </script>

        <style>
        .expand1 { display: none;
        }
        .btn1 { cursor: pointer;
        }
        body {
        background-color: rgb(255,255,255);
        font: 15px Verdana, Helvetica, sans-serif;
        }

        table#t02, #t02 th, #t02 td {
            border: none;
            border-collapse: collapse;
            font-size:90%;
            font-weight:normal;
        }

        #button1{
            position: relative;
            top:10px;
            left:75%;
            color: white;
            background-color: rgb(0,89,132);
            font-weight: bold;
        }
        </style>

    </head>
    <body>
        <form id="form1" method="post" class="admin-form">
            <div style="float:left; width:50%">
                <table id="t02" class="table2">
                    <tr>
                        <th style="padding:0 30px 0 0;"></th>
                        <th></th>
                        <th style="padding:0 10px 0 0;">Green</th>
                        <th colspan="3" style="padding:0 10px 0 0">Yellow</th>
                        <th></th>
                        <th style="padding:0 10px 0 0">Red</th>
                    </tr>
                    <tr>
                        <td class="btn1" style="padding:0 30px 0 0;"><b>Call Volume</b></td>
                        <td>&lt</td>
                        <td style="padding:0 10px 0 0"><input type="number", class="admin-input", name="acd_call_volume_good_high", min="0", value="50"></td>
                        <td><input type="number", class="admin-input", name="acd_call_volume_warning_low", min="50", value="50"></td>
                        <td>to</td>
                        <td style="padding:0 10px 0 0"><input type="number", class="admin-input", name="acd_call_volume_warning_high", min="50", value="100"></td>
                        <td>&gt</td>
                        <td style="padding:0 10px 0 0"><input type="number", class="admin-input", name="acd_call_volume_critical_low", min="100", value="100"></td>
                    </tr>
                    <tr>
                        <td align="center" class="expand1">Day of Job (DOJ)</td>
                        <td class="expand1">&lt</td>
                        <td class="expand1"><input type="number", name="acd_call_volume_good_high_Day of Job (DOJ)", min="0", value="50"></td>
                        <td class="expand1"><input type="number", name="acd_call_volume_warning_low_Day of Job (DOJ)", min="50", value="50"></td>
                        <td class="expand1">to</td>
                        <td class="expand1"><input type="number", name="acd_call_volume_warning_high_Day of Job (DOJ)", min="50", value="100"></td>
                        <td class="expand1">&gt</td>
                        <td class="expand1"><input type="number", name="acd_call_volume_critical_low_Day of Job (DOJ)", min="100", value="100"></td>
                    </tr>
                </table>
                <input type="submit" name="submitButton" value="Submit" id="button1" style="height:50px; width:100px"/>
            </div>
        </form>
    </body>
</html>

CSS:

.expand1 { display: none;
}
.btn1 { cursor: pointer;
}
body {
background-color: rgb(255,255,255);
font: 15px Verdana, Helvetica, sans-serif;
}

table#t02, #t02 th, #t02 td {
border: none;
border-collapse: collapse;
font-size:90%;
font-weight:normal;
}

#button1{
position: relative;
top:10px;
left:75%;
color: white;
background-color: rgb(0,89,132);
font-weight: bold;
}

Answer №1

When utilizing the min option in an HTML input tag, there may be inconsistencies in the visual display.

The purpose of the min attribute for number inputs is to define the minimum value that a user can input, not to control the size or width of the input field.

To restrict the maximum width of these input fields, you should utilize the max-width property in your CSS stylesheet:

input[type=number] {
  max-width: 100px;
}

Note that setting a max-width does not ensure that the input fields will always be at least 100px wide. If you require them to maintain a specific width, use the width property instead.

Also, avoid using commas to separate attributes within the input tags.

If possible, consider using CSS for layout purposes rather than relying on tables. However, the provided solution should address the issue raised in your query. You might want to explore resources on flexbox if you opt to transition away from table layouts.

You can find a runnable snippet below for reference:

{/* Runnable snippet code here */}

Sources:

http://www.w3.org/TR/html5/forms.html#the-min-and-max-attributes

https://developer.mozilla.org/en-US/docs/Web/CSS/max-width

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

When I forget to use var_dump, PHP fails to load scripts

When I am building CSS links using a function, the CSS doesn't work unless I add a var_dump at the end. What could I be missing or overlooking? Here is the code snippet: private function buildCssLinks(){ $files = $this->findFiles(dirname(d ...

Modify the button's color when clicked and add it to an array with JavaScript

I am currently working on changing the color of buttons to indicate a selection. When a button is selected, its value is added to an array. If the same button is clicked again, it becomes unselected and its color reverts back to the original state, with it ...

Navigate to specific location within a hidden overflow

<ul id="the-list" style="overflow:hidden;height:100px;> <li><a id="link1" href="#">Link 1</a></li> <li><a id="link2" href="#">Link 2</a></li> <li><a id="link3" href="#">Link 3< ...

Will my JavaScript function be triggered when the page is resized while printing?

I have a simple HTML layout where I am using the TextFill jQuery library to automatically adjust the text size based on available space. Everything looks good on screen, but when printed, it seems like the page is resized and the JavaScript needs to be re ...

Tips for extracting and utilizing the values of multiple checked checkboxes in a jQuery datatable

When a button is clicked, I am trying to retrieve the selected values of multiple rows from the datatables. However, with my current code below, I am only able to get the value of the first selected row. function AssignVendor() { var table = $(assig ...

What is the method for including preset text within a search bar?

My current issue is as follows: When the searchbox is focused, it appears like this: -------------------- -------------------- Upon exiting the searchbox, a string will automatically be added to it: -------------------- Search -------------------- I a ...

Having trouble incorporating custom elements with the document.execCommand function

I have been attempting to insert a custom element into an editable div using the document.execCommand method as described in detail on https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand. However, when I try to add a custom polymer eleme ...

The JSON file is not filling the options in the dropdown menu

procedure Add the objects from the dropdown into the dropdown menu. The Json file is located in root/ajax/.json and the working file is stored in root/.html. Problem: None of the objects from the JSON file are appearing in the dropdown menu. I attempted ...

Where can I locate HTML codes within WordPress?

Upon inspecting the page source, I came across the following code snippet; I attempted to search within WordPress for the HTML codes that are displayed here, but unfortunately, I was unable to locate them. I couldn't find any files with a .html exte ...

CSS does not alter the properties of a link's "background-color" or "border-color"

I have successfully changed the text color of visited links, but I am struggling to change the "background-color" and "border-color" properties. The initial part of my internal style sheet includes a CSS reset. a:visited { color: red; background-col ...

Having trouble locating images and JavaScript files on GitHub Pages

Using a template from this source to create a react website with interactions involving smart contracts, I successfully got everything up and running smoothly on my localhost. All the features of the site were functioning correctly and images were displayi ...

There appears to be an issue with the onmousemove function

I am currently troubleshooting an issue with a script that I wrote for my button. Interestingly, the code works flawlessly when I test it on CodePen, but I encountered an error when I attempted to run it in VSCode. Even after trying to recreate the script ...

Organize your items vertically using jQuery Mobile's list feature

I am currently working on a mini chat application. The messages in the list are appearing side by side and I would like them to be displayed one below the other. Is there a way to adjust the CSS or add classes to achieve this? <div style="height:100% ...

Tips for designating all content within a <div> element to open in a blank target (target="_blank")

I am looking to open all content within a specific <div> in a new tab (target="_blank"). I am open to any solution, whether it involves JS, CSS, HTML, classes, IDs, etc. I experimented with using <base target="_blank">, but it affect ...

Owl carousel issue: Fixed position not functioning properly

To view the page with the issue, click here I am attempting to make the column (div) day/date headers sticky when they scroll out of view so that users can always see what day they are looking at. Instead of directly manipulating the header itself, I have ...

WordPress Header Display Issue on Mobile and Tablet Devices: What You Need to Know

I'm facing an issue with the header and footer being cut off on mobile devices. When viewed on a tablet or phone, the header doesn't display across the full width of the screen. This problem arises because the Wordpress theme was created in 2010 ...

Add a CSS class to a dropdown menu option in HTML and JavaScript (JQuery) if it has a specified ID

I am brand new to HTML and JQuery, and I'm struggling with setting a class for my select element when the currently selected option has an ID of "answer". This is crucial for checking the correctness of a multiple choice question. If achieving this i ...

Issue resolved: Mysterious fix found for background images not displaying in NextJS React components

I am having trouble displaying a background image on an element in NextJs using Typescript and Tailwind. I do not believe it is a TypeScript issue since I am not receiving any errors or IntelliSense warnings. Below is the code I am working with: var classn ...

Input various colored text within an HTML element attribute

In my asp.net project, I am looking to dynamically change the text color of a table cell based on a certain parameter. Here's an example scenario: TableCell dataCell = new TableCell(); foreach (var o in results) { ...

Ensure that every line of code within the button element contains all the required attributes

Struggling to get the underline on every section of my button. Attempted utilizing the -webkit-box-decoration-break property, but unfortunately it was unsuccessful. It is necessary for both the initial line (New Delhi,) and final line (India) to have an u ...