javascript - Disable submit button if dijit.form.DateTextBox is invalid -


    when user types input in dojotype="dijit.form.datetextbox" "abcd" shows value entered not valid.but allowing user submit form without issues.     wanna disable submit button if invalidmessage attribute of datetextbox shown up. 

i m trying implement function using below code; still m not able acheive functionality datatextbox.on not triggering.i m new dojo.kindly me on this.

function validatesubmit(){           alert('validate');         var datetextbox = dijit.byid("fromdeddate").get('value');         alert('datetextbox value '+datetextbox);         var datetextboxid = dijit.byid("fromdeddate");         alert('datetextbox id '+datetextboxid);         var submitbutton = document.getelementbyid('search');         alert('submitbutton '+submitbutton);         datetextbox.on('change', function(e){         var result = datetextbox.validate();         alert('result');         }); }      <form:input                     path="deductionsearchfilter.deductiondatefrom" size='20'                     id="fromdeddate" dojotype="dijit.form.datetextbox"                     onchange="dijit.byid('todeddate').constraints.min = arguments[0];"                     size="10" style="width: 114"                     title="a single deduction date can entered in from/to fields or range of deduction dates can entered search multiple days." />     <td align='center'><input id="search" onclick="validatesubmit();" type="submit" name="search"                     value="search" class="button"                      title="view results of search" />                 </td> 

you connect change event datetextbox , hook handler. should note won't prevent form submitting when user presses enter.

var datetextbox = registry.byid('datetextbox'); var submitbutton = registry.byid('submitbutton'); datetextbox.on('change', function(e){   var result = datetextbox.validate();   submitbutton.set('disabled', result); }); 

if want more control on forms recommend wrapping form element in dijit/form/form. check reference: http://dojotoolkit.org/reference-guide/1.10/dijit/form/form.html examples.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -