Using this code I disable my submit button on the initial load. I'd like to enable it when the form is valid. I have Prototype.js on my system.
I send back a chunck of html to update my target. Is it possible to send back an id so that I can check that and enable my button?
Or how best should I accomplish this? As you will see I don't know what I'm doing! The real questions for me are in red.
Ajax code ...
<script type="text/javascript">
function run_ajax() {
var url = '/cgidev2p/r_chgpwd.pgm';
var pars = 'v_current='+escape($F('v_current'))+ '&v_new=' + escape($F('v_new')) + '&v_confirm=' + escape($F('v_confirm')) + '&sessionid=' + escape($F('sessionid'));
var target = 'v_messege';
var myAjax = new Ajax.Updater(target, url, {method:'get', parameters:pars});
if (!document.getElementById('success')) return; {
var submitObj = document.getElementById('goButton');
submitObj.disabled = false;
}
}
function init() {
if (!document.getElementById) return;
var submitObj = $('goButton');
submitObj.disabled = true;
}
</script>
<body onload="init()">
Target ...
<div id="v_messege"></div>
Here's the code I send back if the form is valid ...
<div align="left" class="ct26" style="padding-left:5px; width:350px" id="success">
<div class="wraptocenter"><img src="/images/common/check.gif" width="16" height="14"> /%info_note%/</div>
</div>