Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


28,736 Points

Adding contact form step: Submission forms

Hello there, there is something I can't figure out on my own with the submissions forms.

I understand everything correctly till now, but there is something boring me.

That's the fact the form doesn't check really if the inputs are empty or not, so even if I don't fill in inputs, If I click the submit button, I get the "thank you message", telling the message was well received and etc...

Shouldn't we have a message telling instead to fill each inputs if ever some information are missing, this before submiting ?

That would probably means others conditions to check each input... at least I guess.

If anyone could help enlight me on this. Thank you...

2 Answers

Sebastian Limbach
Sebastian Limbach
1,536 Points

To check if the inputs are empty you could write a little bit of JavaScript to hide and show the submit button for example. Here is an example code:

  $('input[type=text]').on("keyup", function(){
    var inputVal = $('input[type=text]').val();
    if(inputVal !== ""){

And here the working example on CodePen. Hope i could help.

Oh and in PHP it would be something like:

if($_POST['text'] == ""){
echo "No input";
28,736 Points

Thank you for your answer, nevertheless, after "googling" about that, I think that we have to check it with the isset() function. Moreover, I've just noticed, the teacher enhances the form in the following videos and check each input. My fault, I want to go to too fast !

Anyway, thank you again Sebastian.