问题描述
我有一个文本框导致一旦链接按钮被触发就会导致冒犯,但是我已经调用了一个javascript函数OnclientClick并且在点击了linkButton后,CausesValidation正在工作...
让我成为一个特定的通过给出一个例子
Javascript代码:
Hi,I have textboxes that causesValidtion once linkbutton get fired if empty,but I have called a javascript function OnclientClick and the CausesValidation is working after the linkButton was clicked...
let me be specifik by giving an exemple
Javascript code:
function generateRandom() {
$('#txtRefcode').val(random());
alert('Reference Code: ' + $('#txtRefcode').val());
return true;
}
function random() {
return Math.floor(Math.random() * 10000000);
}
Html代码:
Html code:
<asp:TextBox ID="txtsname" runat="server" CssClass="TextBox-size">
<asp:RequiredFieldValidator ID="txtsnameRfValidator" runat="server" ErrorMessage="*" Text="Second Name is required" ControlToValidate="txtsname" Display="Dynamic">
<asp:LinkButton id="TigoCash" Cssclass="borderit" runat="server" OnClick="linkbuttonTigoCash_click" CausesValidation="true" OnClientClick="return generateRandom();" >
我想要的是,如果在调用generateRandom()函数之前textbox为空,则causeValidation为true。
What I want is to causesValidation to true if textbox is empty before the generateRandom() function get called.
推荐答案
Html代码:
Html code:
<asp:TextBox ID="txtsname" runat="server" CssClass="TextBox-size">
<asp:RequiredFieldValidator ID="txtsnameRfValidator" runat="server" ErrorMessage="*" Text="Second Name is required" ControlToValidate="txtsname" Display="Dynamic">
<asp:LinkButton id="TigoCash" Cssclass="borderit" runat="server" OnClick="linkbuttonTigoCash_click" CausesValidation="true" OnClientClick="return generateRandom();" >
我想要的是,如果在调用generateRandom()函数之前textbox为空,则causeValidation为true。
What I want is to causesValidation to true if textbox is empty before the generateRandom() function get called.
function generateRandom() {
if(Page_ClientValidate())
{
这篇关于在javascript函数被触发onClientClick之前,CausesValidation为true的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!