I try to use first time the Dojo toolkit and I'm facing an error.
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="/lib/dojo/dojo.js.uncompressed.js"></script>
<title>Insert title here</title>
</head>
<body>
<form enctype="application/x-www-form-urlencoded" action="" method="post">
<dl class="zend_form">
<dt id="teszt-label">
<label for="teszt" class="required">teszt:
</label>
</dt>
<dd id="teszt-element">
<input type="text" name="teszt" id="teszt" value=""
dojoType="dijit.form.ValidationTextBox"
regExp="\d{5}" required="true" invalidMessage="asd" />
</dd>
</dl>
</form>
<script type="text/javascript">// <![CDATA[
dojo.require("dijit.form.ValidationTextBox");
// ]]></script>
</body>
</html>
I got the script from the second example: http://www.dojotoolkit.org/reference-guide/dijit/form/ValidationTextbox.html#dijit-form-validationtextbox
The script must validate the input with the given regular expression. I see in firebug, that it loads all of the required components, but it doesn't work on the input field.
What's wrong?
regExp="\\d{5}"
到regExp: "[\\\\d]{5}"
<script type="text/javascript">
//<![CDATA[
dojo.require("dojo.parser");
dojo.addOnLoad(function(){
dojo.parser.parse();
});
// ]]>
</script>
This code solved the problem.
how about doing this instead?
<script type="text/javascript" src="/assets/dojo/dojo.js" data-dojo-config="parseOnLoad: true, isDebug: true"></script>
isDebug: true
is set if you want some debug messages appearing on browser's console.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.