Erwin van Ekeren Erwin van Ekeren - 1 year ago 51
Javascript Question

Show message instead of alert

I am using this amazing javascript to check if all my fields are filled in but instead of a alert box I want to show a message on my page instead

$(document).ready(function() {
$('form').submit(function() {
var incomplete = $('form :input').filter(function() {
return $(this).val() == '';
//if incomplete contains any elements, the form has not been filled
if(incomplete.length) {
alert('Vul alle velden in en probeer het nog eens');
//to prevent submission of the form
return false;

I tried to play with echo messages but that didn't worked

Answer Source

You can styling your own popup. Or use some plugins.

Or you can create some element on the page, that will showing the error messages. Write some styles and make it look awesome !

<div class="error-messages" style="display:none;"></div>

After the form sending, and checking errors, write this.

$(".error-messages").text("Some error").fadeIn();

Or you can make it empty and hide it, after a seconds or after user focus.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download