I'm developing an ordering system relying on PHP and MySQL; the problem I have is essentially HTML, though, and specifically with Google Chrome (no issue with Firefox or IE).

If an order already exists for a customer, items are listed with input boxes but with the maxlength attribute (a variable in the PHP generating the page) set to zero, so that nothing can be entered.

This works fine, without changing appearance, except in Google Chrome, where any number of digits can be entered for a zero value (it works OK when set to +ve integer).

I can get around this by setting the input type to "hidden" instead of the maxlength but this changes the appearance. Is there any sort of fix/trick to get around this in Chrome?

If the user does not need to interact with that particular element why have it.

You could try the attribute disabled:

<input type="text" name="name" disabled="disabled" />

Same page is used to generate the page whether an order can be made or not - it looks better to have the appearance maintained and there are a number of reasons an order might be blocked, so it's leaner programming to set a variable.

Suggestion appears to work and keeps appearance; thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.