-4

This is my site Liquid Layouts .

The issue i am having is on the register and page, the validation with JS before PHP. I never learned JS, i went PHP route after CSS and every time i put in a JS validation, it will either still proceed to PHP after error or just not pass on to the PHP page if no errors are detected.

All i really want is a definitive answer on what will allow the JS validation to kill process on error and pass to PHP process if all is right

Derek
  • 3
  • 2
  • 3
    Hello, welcome to the site! This is a bad question. I recommend you read [the entire Help Center](http://stackoverflow.com/help) and head back when you have – admdrew Jul 25 '14 at 18:19
  • 1
    As an aside, I hope that you plan to enhance your site and learn to be a web developer before you start offering web development services. – Mike Deluca Jul 25 '14 at 18:24
  • possible duplicate of [How do I cancel form submission in submit button onclick event?](http://stackoverflow.com/questions/4227043/how-do-i-cancel-form-submission-in-submit-button-onclick-event) – Roman Hocke Jul 25 '14 at 18:26
  • how so Michael Deluca – Derek Jul 25 '14 at 18:30
  • The site looks like something that would be spam and created in the 90's. – Mike Deluca Jul 25 '14 at 18:33
  • not much of a critique, is my coding bad?? maybe the design is, but im looking for constructive criticism. – Derek Jul 25 '14 at 18:35
  • The reason why this isn't a good question for Stack Overflow - which someone should have explained already! - is that it refers readers to an external link. Once you have fixed the problem, the question loses its value, since readers can no longer see what you were referring to. Questions therefore must be self-contained for that reason. – halfer Jul 25 '14 at 18:38
  • "Branding will help progress ur business" - it would probably be best to switch that to 'your' - txtspk on a marketing website will chase a good number of customers away. The word 'separate' is misspelled a couple of times too. – halfer Jul 25 '14 at 18:40
  • thanks for clearing that up, i will make sure i post code next time and not use an outside link as the source – Derek Jul 25 '14 at 18:42
  • thanks halfer, good looking out – Derek Jul 25 '14 at 18:43
  • (No probs. If you wish to communicate with individuals here, use the at-symbol followed by their username. You have tab completion, so type the 'at' followed by a letter, and press tab. This alerts the relevant user with a notification icon). – halfer Jul 25 '14 at 18:47

2 Answers2

2

You need to prevent the default action. In this case, you need to prevent de form submit If you are using jquery, you can do something like this

$("form.contact").on("submit", function(e){
     e.preventDefault();

     //do your validation
     if(valid){
          $("form.contact").submit();
     }
});

The submit action (PHP) will occur if js validation is true.

Ellen Kenne
  • 106
  • 3
0

Have a look at the jQuery validate plugin, this is an easy script that will allow you to do what you want. If you are unsure about jQuery, it's just a JavaScript library.

halfer
  • 19,824
  • 17
  • 99
  • 186
TheSk8rJesus
  • 418
  • 2
  • 12