更新面板的Javascript验证问题 [英] Javascript validation issue with update panel

查看:56
本文介绍了更新面板的Javascript验证问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我想从更新面板里面的按钮调用我的javascript函数

我已经写了上面代码但是它的没有调用该函数,因为它在更新面板内。



Hello all,

I want to call my javascript function from my button inside update panel
I have written above code but its not calling that function, as it is inside update panel.

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
   <ContentTemplate>
     <fieldset>
          <asp:Button ID="btnSubmit" runat="server" CssClass="btn"  OnClientClick ="return validate()" onclick="btnSubmit_Click" Text="Submit" Width="109px"/>
           <br />
       <asp:Label ID="lblMessage" runat="server" Font-Bold="True" ForeColor="#FF3300">                      </asp:Label>
          </fieldset>
       </ContentTemplate>
</asp:UpdatePanel>





Javascript函数



< script language =javascripttype =text / javascript>

function validate() {

var summary =;

摘要+ = isvalidProposerName();

摘要+ = isvalidProposlAmount();

摘要+ = isvalidDocRcvdDate();

摘要+ = isvalidDocRcvdTime();

摘要+ = isvalidIntermediaryCode();

if(摘要!=){

提醒(摘要);

返回false;

}

else {

返回true;

}



}

function isvalidProposerName(){

var uid;

var temp = document.getElementById(txtProposerName)。value;

uid = temp.value;

if(uid ==){

return(请输入提议者姓名+\ n);

}

else {

返回;

}

}

函数isvalidProposlAmount(){

var uid;

var temp = document.getElementById(txtProposalAmount)。value;

uid = temp.value;

if(uid ==){

return(Please Enter Proposal Amount+\ n);

}

else {

返回;

}

}

函数isvalidDocRcvdDate(){

var uid;

var temp = document.getElementById(txtDocRcvdDate)。value;

uid = temp.value;

if(uid ==){

return(请输入Doc Rcvd Date+\ n) ;

}

else {

返回;

}

}

函数isvalidDocR cvdTime(){

var uid;

var temp = document.getElementById(txtDocRcvdTime)。value;

uid = temp.value ;

if(uid ==){

return(请输入Doc Rcvd Time+\ n);

}

else {

返回;

}

}

function isvalidIntermediaryCode(){

var uid;

var temp = document.getElementById(txtIntermediaryCode)。value;

uid = temp。价值;

if(uid ==){

return(请输入中介代码+\ n);

}

else {

返回;

}

}

< / script>



Javascript Function

<script language="javascript" type="text/javascript">
function validate() {
var summary = "";
summary += isvalidProposerName();
summary += isvalidProposlAmount();
summary += isvalidDocRcvdDate();
summary += isvalidDocRcvdTime();
summary += isvalidIntermediaryCode();
if (summary != "") {
alert(summary);
return false;
}
else {
return true;
}

}
function isvalidProposerName() {
var uid;
var temp = document.getElementById("txtProposerName").value;
uid = temp.value;
if (uid == "") {
return ("Please Enter Proposer Name" + "\n");
}
else {
return "";
}
}
function isvalidProposlAmount() {
var uid;
var temp =document.getElementById("txtProposalAmount").value;
uid = temp.value;
if (uid == "") {
return ("Please Enter Proposal Amount" + "\n");
}
else {
return "";
}
}
function isvalidDocRcvdDate() {
var uid;
var temp =document.getElementById("txtDocRcvdDate").value;
uid = temp.value;
if (uid == "") {
return ("Please Enter Doc Rcvd Date" + "\n");
}
else {
return "";
}
}
function isvalidDocRcvdTime() {
var uid;
var temp =document.getElementById("txtDocRcvdTime").value;
uid = temp.value;
if (uid == "") {
return ("Please Enter Doc Rcvd Time" + "\n");
}
else {
return "";
}
}
function isvalidIntermediaryCode() {
var uid;
var temp =document.getElementById("txtIntermediaryCode").value;
uid = temp.value;
if (uid == "") {
return ("Please Enter Intermediary Code" + "\n");
}
else {
return "";
}
}
</script>

推荐答案

Hi Sunil,

it looks like your javascript functions have issues, not with update panel.
debug your javascript functions, run your page and see if you get any javascript error in left bottom of browser.


one issue i noticed is:
var temp = document.getElementById("txtProposerName").value;
uid = temp.value;

in above code you are alredy taking value of textbox,but in second line again you are trying to get value. this might throw an error.
rest do your own debugging


谢谢你,你是对的...

我的另一个愚蠢的错误... :)

非常感谢你。
Thanks yaar, you are right...
One more silly mistake by me... :)
Thank you so much.


这篇关于更新面板的Javascript验证问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆