问题
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