Note that there are some explanatory texts on larger screens.

plurals
  1. POfield empty error for pop-up form
    primarykey
    data
    text
    <p>Can I have yout help pleas there,I make a validation field for a popup form :</p> <pre><code> function prepareEventHandlers() { document.getElementById("contact").onsubmit = function () { if (document.getElementById("message").value == '') { document.getElementById("errorMessage").innerHTML = 'the field should not be empty!'; return false; } else { document.getElementById("errorMessage").innerHTML = ''; return true; } }; } window.onload = function () { prepareEventHandlers(); } </code></pre> <p>then the html code : </p> <pre><code>&lt;div id="form-content" class="modal hide fade in" style="display: none;"&gt; &lt;div class="modal-body"&gt; &lt;form class="contact" name="contact" &gt; &lt;label class="label" for="message"&gt;Enter a Message&lt;/label&gt;&lt;br&gt; &lt;textarea id="message" name="message" class="input-xlarge"&gt;&lt;/textarea&gt; &lt;p&gt;&lt;span id="errorMessage"&gt;&lt;/span&gt;&lt;/p&gt; &lt;/form&gt; &lt;/div&gt; &lt;div class="modal-footer"&gt; &lt;input class="btn btn-success" type="submit" value="Send!" id="btnsubmit"&gt; &lt;a href="#" class="btn" data-dismiss="modal"&gt;No!&lt;/a&gt; &lt;/div&gt; </code></pre> <p>and I got this error : </p> <pre><code>TypeError: document.getElementById(...) is null document.getElementById("contact").onsubmit = function () { </code></pre> <p>Any Idea?</p> <p><strong>Edit:</strong></p> <p>OK I add <code>id="contact"</code> to my form so the error is gone but now the popup form is displyaed but when I try to click send with empty or not empty value nothing is happened...</p>
    singulars
    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.
 

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