Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
138
rated 0 times [  145] [ 7]  / answers: 1 / hits: 46019  / 11 Years ago, fri, august 9, 2013, 12:00:00

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.


$(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 it didn't work.


More From » forms

 Answers
5

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



http://jquerybyexample.blogspot.com/2013/01/jquery-popup-window-tutorial-plugins.html



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.



$(.error-messages).empty().fadeOut();

[#76440] Thursday, August 8, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
oliverg

Total Points: 453
Total Questions: 101
Total Answers: 100

Location: Liechtenstein
Member since Wed, Dec 8, 2021
3 Years ago
;