1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr">
<head>
<title>expression rationnelle</title>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
<style type="text/css">
</style>
</head>
<body>
<form name="f" method="post">
<input id="i" name="i" type="text" value="i" />
<button id="b" type="button" onclick="fn();">b</button>
</form>
<script type="text/javascript">
function fn() {
//var rgx = /^[0-9a-zA-Zéèàçêïö !-,\n\'\[\]\?\/]*$/;
var rgx = new RegExp("^[0-9a-zA-Zéèàçêïö !-,\\n\\'\\[\\]\\?\\/]*$");
if (rgx.test(document.getElementById("i").value)) alert("if");
else alert("else");
}
</script>
</body>
</html> |