Note that there are some explanatory texts on larger screens.

plurals
  1. POcannot display label from javascript
    primarykey
    data
    text
    <p>I am validating a form from javascript. <strong>The target is:</strong> if user do not enter value in a required field, an error message will show up and will disappear after few seconds. BUT <strong>The problem is:</strong> The error message don't show up and this is probably because from javascript I am failing to write error message in a label control. BUT, if I use javascript alert instead of displaying the label, it works. </p> <p>The code: Javascript</p> <pre><code>&lt;script type="text/javascript"&gt; function showConfirmation() { $('div#confirmationDV').show(); setTimeout(function () { $('div#confirmationDV').fadeOut(5000); }); } function validateRequiredField() { if (document.getElementById("&lt;%=txtOfferTitle.ClientID%&gt;").value == "") { alert("error.....");//this alert works. document.all("&lt;%=lblConfirmation.ClientID%&gt;").innerHTML = "please enter your business name"; // this does not work document.all("&lt;%=lblConfirmation.ClientID%&gt;").style.color = "red"; showConfirmation(); document.getElementById("&lt;%=txtOfferTitle.ClientID%&gt;").focus(); return false; } return true; } &lt;/script&gt; </code></pre> <p>HTML</p> <pre><code>&lt;div class="round-conf-box" id="confirmationDV"&gt; &lt;div class="round-conf-tl"&gt; &lt;div class="round-conf-tr"&gt;&lt;/div&gt; &lt;div class="round-conf-background_color_top"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="round-conf-box-Content"&gt; &lt;asp:Label ID="lblConfirmation" runat="server" CssClass="confirmationLabel"&gt;&lt;/asp:Label&gt; &lt;/div&gt; &lt;div class="round-conf-bl"&gt; &lt;div class="round-conf-br"&gt;&lt;/div&gt; &lt;div class="round-conf-background_color_bottom"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p> //...some other stuff</p> <pre><code>&lt;asp:ImageButton ID="iBtnSave" runat="server" ImageUrl="~/images/createOffer.png" onclick="iBtnSave_Click" OnClientClick="return validateRequiredField()" /&gt; </code></pre> <p>and in the code behind</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { iBtnSave.Attributes.Add("onclick", "return validateRequiredField()"); //some other stuff }} </code></pre> <p>Would be nice if anyone can help me to find my mistakes.. cheers</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload