如何阻止我的功能启动 [英] How do I prevent my function from launching
问题描述
我有一个功能,可以在点击提交时显示消息,但如果验证未完成,我不想让消息运行。如果我的验证没有完成,如何停止运行消息功能。
这是我的代码:
< script type = text / javascript>
函数thankyou()
{alert('Entry Successful!Thank You。'); }< / script>
I have a function to display a message on click of a submit but I don't want to have the message run if the validations are not completed. How do I stop the message function from running if my validations are not done.
Here is my code:
<script type="text/javascript">
function thankyou()
{ alert('Entry Successful! Thank You.'); }</script>
<asp:Button ID="ButtonSubmit" runat="server" Text="Submit" CssClass="auto-style4" ValidationGroup="textboxes" CausesValidation="true" BorderColor="Red" BorderStyle="Solid" BorderWidth="5px" OnClientClick="thankyou()" />
我尝试了什么:
我不知道怎么做!
What I have tried:
I have no idea how to do this!
推荐答案
在客户端,我们可以使用
Hi,
In Client side we can check whether is valid or not by using
Page_ClientValidate("Some validation group").
如果页面通过所有验证,则返回false,否则返回false。
所以在你的情况下警告之前在thankyou函数中,基于true或false调用此函数它返回给出适当的警报消息。喜欢这个
This could return if true if page passes all validations else will return false.
So in your case before alert in thankyou function, call this function based on true or false it returns give proper alert Message. Like this
function thankyou()
{
if(Page_ClientValidate("textboxes"))
alert("Entry Successfull Thank You");
else
alert("Entry Fails");
}
这篇关于如何阻止我的功能启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!