简体   繁体   中英

alternative for max attribute for cross-browser html5 and PHP

<input type="number" name="amount" max="6" /> HTML5 and PHP

I am using the above code in order.php but in html5. So maybe using some PHP will solve this problem?

This works in: Opera & Chrome

Not working in: Safare, IE & Firefox

In Opera & Chrome it shows me a warning when I exceed value 6 and I can't proceed.

In Safari, IE & Firefox it does not show any warnings and proceeds to checkout.

Are there any alternatives to max? It needs to work in all the above browsers.

Thank you, F4LLCON

I'm going to expand on what Millimoose said and suggest something called a polyfill to help you with this. While HTML5 forms are wonderful, they are not completely supported by every browser yet. But people spend many hours coding scripts that bring this functionality to older browsers while using the default functionality in the browsers that support it!

The one that was mentioned for you was jQuery Tools Validator . It is really the best one for your use case as you can drop it in and not have to write tedious validation rules.

I also recommend checking out this Placeholder script for even more HTML5 goodness in your forms!

Remember when using cutting, new features to always integrate these types of scripts to allow older browsers to enjoy your site too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM