J
Jennifer Mathews
In a form
<asp:ValidationSummary ID="rfvg_Submit" runat="server" />
<asp:TextBox ID="txt_Last_Name" Text="test" runat="server" AutoPostBack="False"
EnableViewState="True" MaxLength="30" />
<asp:RequiredFieldValidator ID="rfv_txt_Last_Name" runat="server"
ControlToValidate="txt_Last_Name" ErrorMessage="whatever" ValidationGroup="rfvg_Submit"
CssClass="ReqrFldValidator_Err_Msg_RghtOfCtl" InitialValue="" Text="*"
SetFocusOnError="True" Display="Dynamic"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="rev_txt_Last_Name" runat="server"
ControlToValidate="txt_Last_Name" ValidationGroup="rfvg_Submit" InitialValue="" Text="*"
SetFocusOnError="True" Display="Dynamic" ErrorMessage="Last Name length is between 2 &
30 characters and can alphanumeric and spaces." ValidationExpression="[
0-9a-zA-Z]{2,30}" />
<asp:ImageButton ID="cmdSave" runat="server" ImageAlign="Middle" ImageUrl="Save.jpg"
ValidationGroup="rfvg_Submit" />
When the user press <SAVE> button it properly validates and doesn't submit itself to the
code-behind. Yeah.
But when I put OnClientClick in the <SAVE> button there is a problem:
<asp:ImageButton ID="cmdSave" runat="server" ImageAlign="Middle" ImageUrl="Save.jpg"
ValidationGroup="rfvg_Submit" OnClientClick="return Validat_cmdSave();" />
JAVASCRIPT
function Validat_cmdSave()
{
var isGood = true;
if (whatever == 1)
{
isGood = false;
}
return isGood;
}
If the JavaScript returns FALSE, the form does NOT post back as expect.
If their is an error in the RequiredFieldValidator or RegularExpressionValidator
validator and
the JavaScript returns TRUE, the form still posts back to the code-beind. I do not want
it
to post back to the code-behind though.
Is there a solution to this?
Thanks
<asp:ValidationSummary ID="rfvg_Submit" runat="server" />
<asp:TextBox ID="txt_Last_Name" Text="test" runat="server" AutoPostBack="False"
EnableViewState="True" MaxLength="30" />
<asp:RequiredFieldValidator ID="rfv_txt_Last_Name" runat="server"
ControlToValidate="txt_Last_Name" ErrorMessage="whatever" ValidationGroup="rfvg_Submit"
CssClass="ReqrFldValidator_Err_Msg_RghtOfCtl" InitialValue="" Text="*"
SetFocusOnError="True" Display="Dynamic"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="rev_txt_Last_Name" runat="server"
ControlToValidate="txt_Last_Name" ValidationGroup="rfvg_Submit" InitialValue="" Text="*"
SetFocusOnError="True" Display="Dynamic" ErrorMessage="Last Name length is between 2 &
30 characters and can alphanumeric and spaces." ValidationExpression="[
0-9a-zA-Z]{2,30}" />
<asp:ImageButton ID="cmdSave" runat="server" ImageAlign="Middle" ImageUrl="Save.jpg"
ValidationGroup="rfvg_Submit" />
When the user press <SAVE> button it properly validates and doesn't submit itself to the
code-behind. Yeah.
But when I put OnClientClick in the <SAVE> button there is a problem:
<asp:ImageButton ID="cmdSave" runat="server" ImageAlign="Middle" ImageUrl="Save.jpg"
ValidationGroup="rfvg_Submit" OnClientClick="return Validat_cmdSave();" />
JAVASCRIPT
function Validat_cmdSave()
{
var isGood = true;
if (whatever == 1)
{
isGood = false;
}
return isGood;
}
If the JavaScript returns FALSE, the form does NOT post back as expect.
If their is an error in the RequiredFieldValidator or RegularExpressionValidator
validator and
the JavaScript returns TRUE, the form still posts back to the code-beind. I do not want
it
to post back to the code-behind though.
Is there a solution to this?
Thanks