in my requirement, i am require to use 1 editor and requiredfieldvalidator doesn't work on this Editor control. So i am validating this control through javascript and rest of the asp.net control through asp controls validator on a single click of a button.
I am trying to implement server side validation through aspnet server side control and client side validation through javascript. i have two textbox control and one submit button as follows :
<div>
<asp:TextBox ID="Txt1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RfvTxt1" runat="server" ErrorMessage="*" ForeColor="Red"
ControlToValidate="Txt1"></asp:RequiredFieldValidator>
<asp:TextBox ID="Txt2" runat="server"></asp:TextBox>
<asp:Button ID="btnsubmit" runat="server" OnClick="btnsubmit_Click" Text="Submit"
OnClientClick=" return ss();" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
<script src="JS/jquery-1.7.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
function ss() {
var script = $("#<%=Txt2.ClientID %>").val();
if (script == "") {
alert(1);
return false;
}
}
</script>
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = "dd";
}
protected void btnsubmit_Click(object sender, EventArgs e)
{
Label1.Text = "ss";
}
but both the validation doesn't work. problem is, when the second textbox contains the Text. The page postback and runs it event even if the first Textbox doesn't contain its text. Thanks for any assistance.
ss()
defined and what does it contain? – robertc