[Javascript] Newbie - Understanding a piece of code

MEM talofo at gmail.com
Mon Oct 5 18:39:00 CDT 2009


Hello all,

I'm using a validation class because, despite my efforts, I couldn't create
a validation class in time, so I'm ashamed for using someone else's code
without properly understand it. I really am, so please, spare me for now...
I'm already on a bad conscience... :s


On the form element, I have:
<form id="enviarDados" action="<?php echo filter_var($_SERVER['PHP_SELF'],
FILTER_SANITIZE_STRING) ?>" method="post" enctype="multipart/form-data"
onsubmit="myOwnSubmit();">

And more at the bottom, I have:

function myOwnSubmit()
{
     //instanciate the validation class
				
     //the instance method validate will return boolean value
     var result = valid.validate();
     
     if (result == true)
     {
          document.getElementById('submit_bt').disabled = true;
     }
}

I was expecting that, once the onsubmit is called, the validation takes
place. Once the validation fields are error clean, (the result is true), it
will disable the submit button with the id of 'submit_bt'.

However, the button only gets disabled for a few seconds, and worst of all,
no form data are getting submitted.


I'd like to understand what's going wrong and, above all, what I'm not
getting, that I should, in order to properly understand, how something like
this should work.


Thanks in advance,
Márcio




More information about the Javascript mailing list