Using a form with validation within a lightbox

Jessica Knaak asked on August 10, 2016 17:07


I am trying to have a form that will use validation (both for empty fields and for a valid email address) inside of a lightbox. I do not believe kentico has a lightbox webpart that this would work with. So, I have created my own.

It's a fairly simple lightbox:

<div class="lightbox-bg"></div>
<div class="lightbox">
<div class="lightbox-inner">
<div style="width: 100%; background: #ccc; padding: 20px 0px; margin-bottom: 15px;"><h2>Title of Lightbox</h2><span>X</span></div> -- IS PUT BEFORE THE FORM I'M USING


It is a custom webpart form but is a viewBiz form. Everything is working great except when someone doesn't enter a valid email address or leaves something blank. The form validation is working correctly so it is not sending the form, but the lightbox is disappearing because the page refreshes when the form is submitted.

Is there any way to have the lightbox not close when the submit button is clicked? I tried preventDefault() and that didn't work. I also tried having the lightbox fadeIn() when the submit button is clicked to see if maybe the lightbox would just come back right away. That didn't work either. Any ideas would be greatly appreciated.

Thank you!

Correct Answer

Rui Wang answered on August 10, 2016 17:36

Hi Jessica

In the property of the web part it should have an Ajax section which you can enabled the update panel. By default, the validation triggers a post back, so that might by why your light box went away. But with Ajax enabled, it shouldn't require post back for validation.

0 votesVote for this answer Unmark Correct answer

Recent Answers

Jessica Knaak answered on August 10, 2016 17:40

Ah ha! Thank you so much Rui! I figured it was something simple that I was missing.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.