validateForm() function doesn't work


Topic: validateForm() function doesn't work

MendipFlyer asked 5 years ago

Expected behavior form should get sent or show error if field is missing

Actual behavior no response on send

Resources (screenshots, code snippets etc.) I'm using the basic contact form code. This worked OK until I inserted the javascript validation - now nothing happens. what am I missing? http://dave.p2net.co.uk/index.html


MendipFlyer answered 5 years ago

OK, it seems that there is no element called id on the page and so missing field errors were not being shown. Simples


Grzegorz Bujański staff commented 5 years ago

Hi.

But it's ours mistake. We add <div class="status"></div> in html and try to catch this element by ID. we will fix it in our documentation.

Best, Grzegorz


MendipFlyer answered 5 years ago

Right, so now I'm working through the section that uses Ajax to return to the form after sending. Firstly, before entering anything on the form page the status says 'name cannot be empty'. Then, after completing form, the page mail.php appears with json message 'Email successfully sent' code: 1. This does not return me to the form. What am I missing now? http://dave.p2net.co.uk/index.php


Grzegorz Bujański staff commented 5 years ago

Did you use this in your code? https://mdbootstrap.com/docs/jquery/forms/contact/#ajax


MendipFlyer commented 5 years ago

Hi, Thanks, yes I was using that code, but it was not clear to me that it had to replace 'just' the lines document.getElementById('status').innerHTML = "Sending..."; document.getElementById('contact-form').submit(); in the previous javascript. it seems to be working now


Grzegorz Bujański staff commented 5 years ago

I'm glad you have solved the problem

Best, Grzegorz


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: General Bootstrap questions
  • MDB Version: -
  • Device: laptop
  • Browser: firefox
  • OS: windows 10
  • Provided sample code: No
  • Provided link: Yes