javascript - Enable/Disable a button using dojo toolkit -
i have declared button in html , want dynamically enable/disable using javascript , dojo toolkit.
i have made following code, should minimal working example:
<html> <head> <script language="javascript" type="text/javascript"> require(["dojo/dom", "dojo/on", "dojo/request", "dojo/domready!"], function(dom, on, request){ on(dom.byid("password"), "keyup", function(evt){ request.get("/passwordchecker", { query: { user: document.getelementbyid("username").value, pass: document.getelementbyid("password").value } }).then( function(response){ if(strength === "strong") { dijit.byid("ok").setattribute('disabled',false); } } ); }); } ); </script> </head> <body> <input id="username" type="text"/> <input id="password" type="text"/> <button id="ok" dojotype="dijit.form.button" type="submit" disabled="disabled">ok</button> </body> </html>
in other words want user enter password. use ajax check if strong enough , if want enable ok-button.
i rewrote code follows:
function updateokbutton(strength) { if(strength === "strong") { // domattr.set(okbutton, 'disabled', false); require(['dojo/on', 'dojo/dom', 'dojo/dom-attr'], function (on, dom, domattr) { var okbutton = dom.byid("ok"); domattr.set(okbutton, 'disabled', false); }); } }
Comments
Post a Comment