我无法让我的脚本输出所需的验证或错误

时间:2014-01-25 02:46:02

标签: javascript xhtml-1.0-strict

如果有人可以帮我解决下面的代码,我将非常感激。我在IE中使用过调试器,但它没有给我任何错误。要求是XHTML Strict。谢谢!

<!DOCTYPE html
 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title> "Numeric Verification" </title>
<script type="text/javascript">
  <![CDATA[


function parseError(elem) {
    var enteredChar = elem.value.charAt(elem.value.length - 1);
    if (enteredChar === '') return;
    if (enteredChar.match(/[a-zA-Z]/))
        throw "value of " + (elem.name || elem.id) + " must be a digit";
}

document.myForm.value.onkeypress = function() {
    parseError(this);
};

]]>
</script>
</head>

<body>

<form action="#">
<div id="result">

<form name="value">
    <label for="value">Enter Numeric Value </label><input type="text" name="Value" />
</div>
</form>

0 个答案:

没有答案