G
Grant Merwitz
hi
I am using Javascript to do my validation
This is so i can display a loading message after a form is submitted.
Now, currently i do so like this.
I have a button, textbox and label like so:
<asp:textbox id="tb" runat="server"/>
<asp:Button id="btn" runat="server" text="Submit" />
<asp:Label id="lbl" runat="server" />
I then have a javascript function like so:
function validate()
{
if(document.getElementById('tb').value == '')
{
document.getElementById('lbl').innerHTML = "please fill in
textbox";
return false;
}
else
{
document.getElementById('lbl').innerHTML = "Loading...";
return true;
}
}
And i attach this to the button in the code behind like so:
btn.Attributes.Add("onclick", "JavaScript: return validate();");
now, this works perfectly.
but what i would like to do, is disable the button if the value returned is
true.
Like this:
else
{
document.getElementById('lbl').innerHTML = "Loading...";
document.getElementbyId('btn').enables = false;
return true;
}
But when i try this, the form will not submit.
How can i achieve what i'm trying to do here?
Submit a form only if validated, and disable the button if so?
TIA
Grant
I am using Javascript to do my validation
This is so i can display a loading message after a form is submitted.
Now, currently i do so like this.
I have a button, textbox and label like so:
<asp:textbox id="tb" runat="server"/>
<asp:Button id="btn" runat="server" text="Submit" />
<asp:Label id="lbl" runat="server" />
I then have a javascript function like so:
function validate()
{
if(document.getElementById('tb').value == '')
{
document.getElementById('lbl').innerHTML = "please fill in
textbox";
return false;
}
else
{
document.getElementById('lbl').innerHTML = "Loading...";
return true;
}
}
And i attach this to the button in the code behind like so:
btn.Attributes.Add("onclick", "JavaScript: return validate();");
now, this works perfectly.
but what i would like to do, is disable the button if the value returned is
true.
Like this:
else
{
document.getElementById('lbl').innerHTML = "Loading...";
document.getElementbyId('btn').enables = false;
return true;
}
But when i try this, the form will not submit.
How can i achieve what i'm trying to do here?
Submit a form only if validated, and disable the button if so?
TIA
Grant