Multiple forms

Multiple forms

Hey everyone hope your all well and can help me get my head round this situation i have

Ok so im currently printing out some placeholders / div blocks in a while loop using php which have forms within them, to access the forms you have to toggle the div for each of the blocks, that all works flawlessly.

My issue is i need to try and validate which ever form the user has toggled into view to input there details which is just a name and email and then allow them values to be passed back to a php script for processing. I have assigned an ID to each of the forms and was trying to use that id when they clicked the submit button in order to know which form to validate and process. As you see in the script below i had tried putting the ID on a link tag to see if i could then use that variable to go with the submit button that is pressed

I hope what im asking or am trying to do can be done and gratefully appreciate you taking the time to help me out in advance

The script
  1. jQuery(function($){
  2. $(".toggle-btn").click(function(){
  3. //get the submit btn id from the bigBtns
  4. var ID = $(this).attr('id');
  5. $(".error").hide();
  6. $("#subBtn_"+ID).click(function(){
  7. $(".error").hide();
  8. var n = $("input#n").val();
  9. if(n == ""){
  10. $("#nError").text("This field is required.").show();
  11. $("input#n").css("border", "1px solid #F90A0A");
  12. $("input#n").focus();
  13. return false;
  14. } else {
  15. $("input#n").css("border", "none");
  16. }
  17. var e = $("input#e").val();
  18. if(e == ""){
  19. $("#eError").text("This field is required.").show();
  20. $("input#e").css("border", "1px solid #F90A0A");
  21. $("input#e").focus();
  22. return false;
  23. } else {
  24. $("input#e").css("border", "none");
  25. }
  26. });
  27. });
  28. });