input field validation does not work under internet explorer 11 why

半世苍凉 提交于 2019-12-22 14:13:13

问题


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>

回答1:


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



来源:https://stackoverflow.com/questions/32587116/input-field-validation-does-not-work-under-internet-explorer-11-why

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!