Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Modal dialog getting closed on submit and without processing form

    • 0
    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 321
    Answer it

    I have a modal that when opened through ajax displays a form with a submit button. The modal is getting opened successfully but when I am submitting the data in the form the modal disappears without doing the requisite function.

    I have tried many things but all in vain. Nothing seems to work. Looking forward for suggestions and advices in this regard.

    I am not an expert in programming but have the passion for learning programming online.

    Any help in this regard shall be very much obliging.

    Now,

    Following is the link which opens my modal-

    <a href="prslink-new.php" class="okhlink1" rel="modal:open">Retrieve it!</a>
    
    The modal get opened with the form and the validation script -
    
    <?php
    if(isset($_POST["submit"])){
    $mailid = filter_input(INPUT_POST, 'emailid');
    if(empty($mailid)){
      $errors[] = "Email Id left blank.";
    }
    elseif((!preg_match('/^[A-Za-z0-9][A-Za-z0-9._-]+[^-_@!#$%&*()?.,]\@[A-Za-z0-9]+\.[a-z.]{2,}/',$mailid))) {
      $errors[] = "Invalid Email Id.";
    }
    elseif(!$errors) {
      $success = true;
      $successmsg = "No Issue!";
    }
    }
    ?>
    
      <body>
        <?php if($errors){ echo '<div><ul>';foreach($errors as $error){echo '<li>'.$error.'</li>';}'</ul></div>';} ?>
        <?php if($success){ echo '<div>'.$successmsg.'</div>';} ?>
        <form id="form1" action="" class="" method="post" autocomplete="off">
          <div>
            <fieldset>
              <div>
                <label class="fhead" for="emailid">Email Id</label>
                <input class="ftext" id="emailid" name="emailid" type="text" maxlength="60"value="" />
              </div>
                <div><input class="sbmt" type="submit" name="submit" id="submit" value="Submit" /></div>
            </fieldset>
          </div>
        </form>
        <script>
    
    
        </script>
      </body>


    Kindly note that I am calling the ajax library in the <head> section.

    I think this would need some JavaScript but then again I wish to inform that I have tried many but none of them worked and thus I have left the space blank for an appropriate suggestion.

 1 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: