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
- jQuery(function($){
-
- $(".toggle-btn").click(function(){
- //get the submit btn id from the bigBtns
- var ID = $(this).attr('id');
-
- $(".error").hide();
- $("#subBtn_"+ID).click(function(){
-
- $(".error").hide();
- var n = $("input#n").val();
- if(n == ""){
- $("#nError").text("This field is required.").show();
- $("input#n").css("border", "1px solid #F90A0A");
- $("input#n").focus();
- return false;
- } else {
- $("input#n").css("border", "none");
- }
-
- var e = $("input#e").val();
- if(e == ""){
- $("#eError").text("This field is required.").show();
- $("input#e").css("border", "1px solid #F90A0A");
- $("input#e").focus();
- return false;
- } else {
- $("input#e").css("border", "none");
- }
-
- });
-
- });
-
- });