javascript - How do I validate CSV file format using onclick function? -


how can validate csv format , using "required" in html form validate null value. try use onclick function validate using alert box alert box not function after add php code inside javascript. below code. can suggest solution me?

<?php   require_once "lib/base.inc.php"; ?>  <script> function storequeemail(){  <?php         $file = $_files[csv][tmp_name];      $handle = fopen($file,"r");       //loop through csv file , insert database      {          if ($data[0]) {              $record['contact_first'] = $data[0];             $record['contact_last'] = $data[1];             $record['contact_email'] = $data[2];             $record['subject'] = $_request['subject'];             $record['message'] = $_request['message'];             $record['status'] = 0;              $oadminemail->insertqueemail($record);             }      } while ($data = fgetcsv($handle,1000,",","'"));       ?>;      alert('jyfkyugu');     window.location.href="cronjob_sendemail.php"; </script> <html xmlns="http://www.w3.org/1999/xhtml">    <head>      <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />      <title>import csv file php & mysql</title>    </head>    <body>      <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1" >        subject : <br/>       <input type="text" name="subject" id="subject" required/> <br/>       choose file: <br />        <input name="csv" type="file"id="csv" required/> <br/>       content : <br/>       <textarea name="message" cols="50" rows="10" required></textarea><br/>       <input type="submit" name="submit" value="submit" onclick="storequeemail()"/>      </form>    </body>  </html>  


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -