| | |
JS - Display a msg for only a few seconds
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
•
•
i have a form.. i validated it..
if the form has an empty field, instead of popping up an alert box, i need to display a message that goes off say after 5 seconds..
any idea of how to do it?
Example of creating one:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
var msg = documement.createElement('div'); msg.innerHTML = 'Your message';
Then attach that div to whatever element you want it to display on:
eg:
HTML:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<p class="field"> <label for="form-field-id">Label</label> <input id="form-field-id" name="form-field-id" /> </p>
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
// create message element var msg = documement.createElement('div'); msg.innerHTML = 'Your message'; // attach it to the DOM var field = document.getElementById('form-field-id'); field.parentNode.appendChild(msg);
That would append it as a child of <p class="field"> which is the parentNode of <input id="form-field-id" name="form-field-id" />.
To remove it you set a timer.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
clearTimeout(timer); timer = setTimeout(function() { msg.parentNode.removeChild(msg); }, 5000);
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
![]() |
Similar Threads
- retrieve from db and display in a jsp file (Java)
- i need help with this assignment (C++)
- using if-else (C++)
- Seconds timer (C++)
- uaer presses 'x' (VB.NET)
- c++ 2d array (IT Professionals' Lounge)
- Timer question: Scoreboard (VB.NET)
- Python Sleep Function: (Python)
- C++ Baby steps (C++)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Line numbering for javascript.
- Next Thread: Access content page texbox from javascript in JS file
| Thread Tools | Search this Thread |
acid2 ajax ajaxexample ajaxjspservlets array beta box browser captchaformproblem cart child class close codes column css date debugger decimal dependent design disablefirebug dom download editor element embed engine enter error events explorer ext file firefox focus form forms frameworks getselection google gwt gxt hiddenvalue highlightedword hint html htmlform ie7 ie8 iframe index java javascript javascripthelp2020 jquery jsf jsp jump libcurl listbox maps masterpage math media menu microsoft mimic mp4 object onmouseoutdivproblem onmouseover onreadystatechange parent paypal pdf php player position post problem programming prototype redirect safari scale scriptlets scroll search security select software toggle unicode variables w3c web window windowofwords \n






