FORUMS


Hello There, Guest! Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Validation help for a NooB (JS?)
#1
I have created a form, and it is working great!
The only thing I would like to do is prevent duplicate text box entries for a certain field (empire_name)

The form is FormBuilder type, Published

For what I am reading I need to use the JS validation method?
https://docs.formtools.org/userdoc/field...eld_dialog
https://docs.formtools.org/tutorials/js_validation/

How / Where do I make the changes?
I seem to be missing something, probably simple....

Thanks!

Mike
Reply
#2
Bump?
Still trying to figure this out...
Reply
#3
Bump?
Reply
#4
baaah tool its great but support its very hard :S
it should be a premium support Tongue
Nelson Costa.
Reply
#5
(May 1st, 2017, 1:02 PM)eris667 Wrote: Bump?

Is this a internal or external form.  If external, can you paste it here?  Remove any sensitive info of course.

Here's a snippet for a single field and what is required for a external form.  All the below is in a single .php file, but pruned to just show the minimum fields.

Registration Page

PHP Code:
<?php
require_once("/xxx/xxx/formtool/global/api/api.php");
$fields ft_api_init_form_page(2);

// validation time!
$errors = array();
if (isset(
$_POST['sbmt']))
 
    {
 
   $rules = array();
 
    $rules[] = "required,firstname,Please enter your first name.";
 
    $rules[] = "letters_only,firstname,Please only use letters for your first name. *-No spaces/numbers/etc.";
 
    $errors validate_fields($_POST$rules);
 
   
// no errors - great! Now we process the page. The ft_api_process_form does
// the job of both updating the database and redirecting to the next page
 
   if (empty($errors))
 
        {
 
       $params = array(
 
           "submit_button" => "sbmt",
 
            "next_page" => "https://www.xxxx.com/wp/thank-you/",
 
            "form_data" => $_POST,
 
            "finalize" => true
            
);
 
        ft_api_process_form($params);
 
        
// it failed validation. Update $fields with the latest contents of the form data
 
   else
         
{
 
       $fields array_merge($_SESSION["form_tools_form"], $_POST);
 
        
 
   
?>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<title>Registration Form</title>
<link rel="stylesheet" type="text/css" href="registration.css">
</head>
<body>

<?php
// if $errors is not empty, the form must have failed one or more validation
// tests. Loop through each and display them on the page for the user
if (!empty($errors))
 
    {
 
   echo "<div class='error'>Please fix the following errors:\n<ul>";
 
    foreach ($errors as $error)
 
    echo "<li>$error</li>\n";
 
    echo "</ul></div>";
 
   
?>

<!-- Start of FORM -->
<div align="center">
<form action="<?php echo $_SERVER["PHP_SELF"]?>" method="POST">
  <table border="1" cellpadding="5" cellspacing="1" width="800">
    <tbody>
      <tr align="center">
        <td colspan="2" rowspan="1" valign="top"> <h2>HEADER 2</h2></td>
      </tr>
      <tr align="center">
        <td rowspan="1" colspan="2" valign="top" width="618"><BIG><BIG><B>TITLE<br>
        </td>
      </tr>
      <tr>
        <td align="right" valign="top" width="35%">First Name<br>
        </td>
        <td valign="top" width="618"><input maxlength="30" size="30" type="text" name="firstname" value="<?=@$fields["firstname"]?>" /> *-Required</td>
      </tr>
      <tr>
        <td colspan="2" rowspan="1" valign="top">
        <div align="center">Please confirm everything is correct before you submit!<br><input name="sbmt" value="Submit/Validate Form" type="submit"> </div>
        </td>
      </tr>
    </tbody>
  </table>
</form>
</div>
<!-- End of FORM -->
</body>
</html> 


You'll have to read through the options for the different field types, but the above should give you a base page to start with.  Hopefully, I didn't bork anything up by removing too much for this example.

Lyle
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)