iOS警报消息

时间:2018-11-13 10:24:56

标签: iphone

我在开发的剧院网站上遇到了一个小问题。整个站点都可以正常工作,直到在iphone上进行预订为止-发送提交表单后,会出现一条消息:“数值必须小于或等于0”,紧接在数字输入元素下方。也许答案在那里,只是瞪着我的脸,但对于我的一生,我无法弄清楚。有人可以帮我解决这个问题吗?

下面是有问题的输入字段:

<input id="box1" class="number-input inum tgv-index" min="0" name="nietleden" type="number" inputmode="numeric" pattern="[0-9]*"/>

1 个答案:

答案 0 :(得分:0)

这似乎为我解决了问题。我将以下代码放在header.php中。要确定是否正在使用iOS系统,它将把数字输入元素属性更改为文本输入属性。

			function getMobileOperatingSystem() {
				
				var userAgent = navigator.userAgent || navigator.vendor || window.opera;  				
				if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
					setTimeout(function() {
						showMessage('init');
						document.querySelector('#box1').setAttribute('type', 'text');
						document.querySelector('#box2').setAttribute('type', 'text');
						document.querySelector('#box3').setAttribute('type', 'text');					
					}, 2000);
				}
			}
			getMobileOperatingSystem();