输入字段验证在Internet Explorer 11下不起作用 [英] input field validation does not work under internet explorer 11 why

查看:52
本文介绍了输入字段验证在Internet Explorer 11下不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无法获取以下代码来对电子邮件进行字段验证,并且仅接受按照我的代码输入的某些电子邮件..此代码在接受Internet Explorer 11的所有浏览器中均有效,如何才能采用此代码在IE 11下工作仅接受来自某些电子邮件格式的地址...

在I.E. 11-它会检查空白字段,但我无法使电子邮件模式正常工作(html5)如何在IE 11下使其正常工作,它可以在其他浏览器上正常工作,谢谢,谢谢...

 <?php
if(isset($_POST["Subscribe"])){ //name of submit button
    foreach($_POST as $fieldName => $value){
        if($fieldName!="Subscribe"){ //if not submit button
            $fieldValue=$value;
            if($fieldValue == "") {
                echo "Cannot leave ".$fieldName." blank";
                die();
            }
        }
    }
}
?>

<script>
function IsEmpty(){
  if(document.forms['frm'].email.value == "")
  {
    alert("empty field");
    return false;
  }
    return true;
}
</script>

<form name="frm" class="test" method="post" action="myform.php" >
<fieldset><legend><strong>test</strong></legend> 
<p>testing my code...</p>

<p><label for="email">Email address:</label>
<input title="enter email" required="required" name="email" type='email' pattern=".+(@hotmail.com)|.+(@gmail.com)" required />

</p>
 <input id="insert" onclick="return IsEmpty();" style="float: right;" type="submit" name="submit" value="Subscribe" />
</fieldset>

</form> 

解决方案

通过在顶部添加以下代码

来解决此问题

 <!DOCTYPE html> 
<html> 
  <head> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">  

这使I.E变得边缘化,我的所有消息输出和电子邮件验证现在都在工作...再次感谢所有帮助我的人,请谨慎

Unable to get the following code to do field validation for email and to accept only certain emails input as per my code..this code works in all browsers accept Internet explorer 11, how can adopt this code to work under I.E 11 to only accept from certain email format addresses...

under I.E. 11 - it checks for empty field ok but i can not get the email pattern to work (html5) how can i get it to work under IE 11, it works on other browsers okay, thanks in advance...singhy

<?php
if(isset($_POST["Subscribe"])){ //name of submit button
    foreach($_POST as $fieldName => $value){
        if($fieldName!="Subscribe"){ //if not submit button
            $fieldValue=$value;
            if($fieldValue == "") {
                echo "Cannot leave ".$fieldName." blank";
                die();
            }
        }
    }
}
?>

<script>
function IsEmpty(){
  if(document.forms['frm'].email.value == "")
  {
    alert("empty field");
    return false;
  }
    return true;
}
</script>

<form name="frm" class="test" method="post" action="myform.php" >
<fieldset><legend><strong>test</strong></legend> 
<p>testing my code...</p>

<p><label for="email">Email address:</label>
<input title="enter email" required="required" name="email" type='email' pattern=".+(@hotmail.com)|.+(@gmail.com)" required />

</p>
 <input id="insert" onclick="return IsEmpty();" style="float: right;" type="submit" name="submit" value="Subscribe" />
</fieldset>

</form>

解决方案

managed to sort this problem by adding the following code at top

<!DOCTYPE html> 
<html> 
  <head> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 

this renders the I.E to edge and all of my message output and email validation is working now...thanks again for all those helped me, take care singhy

这篇关于输入字段验证在Internet Explorer 11下不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆