Search code examples
htmlmodernizrhtml5shiv

Modernizr required pattern doesn't work


I try to use some html5 content on ie 7-8, to do so, i use Modernizr, but it's not working so far.

I want to use required pattern to validate my form input (because its pretty :)).

my jsp :

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="js/html5shiv.js" type="text/javascript"></script>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Ask email</title>
<link rel="stylesheet" type="text/css"
href="<%=request.getContextPath()%>/css/portail.css" />
</head>
<body>
<jsp:include page="header.jsp" />
<form:form method="POST" action="/it-portail/createdLink.mvc">
    <table class="requestEmail">
        <tr>
            <td><label for="email">Email:</label></td>
            <td><input type='email' required
                pattern=".*@blabla\.fr|.*@toto\.com"
                x-moz-errormessage="Entrer votre email (blabla.fr ou toto.com)"
                name="email" id="email" class="inputText" size="35" maxlength="49"
                value="" /></td>
        </tr>
        <tr>
            <td colspan="2"><input type="submit" value="Submit" /></td>
        </tr>
    </table>
</form:form>
</body>
</html>

i put an alert('test') in js script and it printed out. (.js is linked correctly)

it's working on firefox.

Any idea ?


Solution

  • Modernizr only serves to detect support for HTML5 features.
    It doesn't add support on older browsers.

    Instead, you want a polyfill, which does.

    html5shiv fixes a specific bug in IE<9 which prevents CSS rules from applying to elements with unrecognized names (new HTML5 elements). It does not add any new functionality.