Some errors were detected in your form:
The following required field(s) are missing: Name, Company, Phone number
[[!FormIt? &hooks=`spam,email,redirect` &emailTpl=`emailContact` &emailSubject=`Contactformulier masked.nl` &emailTo=`[email protected]` &redirectTo=`45` &validate=`naam:required,email:email,bedrijf:required,bericht:required` ]] <div class="wrapper contact main"> [[+fi.error.error_message]] <form id="formContact" name="formContact" method="post" action="[[~[[*id]]]]"> <input type="hidden" name="nospam:blank" value="" /> <div class="input naam extend [[!+fi.error.naam:notempty=`error`]]"> <label for="naam">Naam:</label> <input type="text" name="naam" id="naam" value="[[+fi.naam]]" /> </div> <div class="input email extend [[!+fi.error.email:notempty=`error`]]"> <label for="email">E-mailadres:</label> <input type="text" name="email" id="email" value="[[+fi.email]]" /> </div> <div class="input bedrijf extend [[!+fi.error.bedrijf:notempty=`error`]]"> <label for="bedrijf">Bedrijf:</label> <input type="text" name="bedrijf" id="bedrijf" value="[[+fi.bedrijf]]" /> </div> <div class="input bericht extend [[!+fi.error.bericht:notempty=`error`]]"> <label for="bericht">Bericht:</label> <textarea name="bericht" id="bericht">[[+fi.bericht]]</textarea> </div> <input type="submit" name="submit" id="submit" value="Submit" /> </form> </div>
[[!FormIt? &hooks=`spam,email,redirect` &emailTpl=`emailContact` &emailSubject=`Contactform` &emailTo=`[email protected]` &emailHtml=`true` &redirectTo=`41` &customValidators=`FormItValidator` &validate=` naam:required:FormItValidator:stripTags, email:email:FormItValidator:stripTags, bedrijf:required:FormItValidator:stripTags, bericht:required:FormItValidator:stripTags` ]] <div class="wrapper contact main"> [[!FormItValidator? &checkValidation=`true` &Htmltag=`p`]] <form id="formContact" name="formContact" method="post" action="[[~[[*id]]]]"> <input type="hidden" name="nospam:blank" value="" /> <div class="input naam extend [[!+fi.error.naam:notempty=`error`]]"> <label for="naam">Naam:</label> <input type="text" name="naam" id="naam" value="[[+fi.naam]]" /> </div> <div class="input email extend [[!+fi.error.email:notempty=`error`]]"> <label for="email">E-mailadres:</label> <input type="text" name="email" id="email" value="[[+fi.email]]" /> </div> <div class="input bedrijf extend [[!+fi.error.bedrijf:notempty=`error`]]"> <label for="bedrijf">Bedrijf:</label> <input type="text" name="bedrijf" id="bedrijf" value="[[+fi.bedrijf]]" /> </div> <div class="input bericht extend [[!+fi.error.bericht:notempty=`error`]]"> <label for="bericht">Bericht:</label> <textarea name="bericht" id="bericht">[[+fi.bericht]]</textarea> </div> <input type="submit" name="submit" id="submit" value="Submit" class="button" /> </form> </div>
<?php if($checkValidation=='true') { //Echo error if(!$modx->FItmpString) { //No errors show default intro text echo '<'.$Htmltag.' class="contactUs">'.$modx->lexicon('formit.formIntro').'.</'.$Htmltag.'>'; } else { // Errors, show default error message $modx->FItmpString = substr($modx->FItmpString,0,-2); echo '<'.$Htmltag.' class="error">'.$modx->lexicon('formit.formErrors').$modx->lexicon('formit.formErrorsMissing').$modx->FItmpString.'.</'.$Htmltag.'>'; unset($modx->FItmpString); } return; } else { //check POSTed vars if ($validator->errors[$key]) { if($modx->FItmpString == "" OR !$modx->FItmpString) { $modx->FItmpString = $key.', '; } else { $modx->FItmpString .= $key.', '; } return false; } else { return true; } }
formit.formErrors = <strong>Some errors were detected in your form</strong><br/> formit.formErrorsMissing = The following required field(s) are missing: formit.formIntro = Your personal intro message, use below bla bla bla
<?php /* Snippet parameters */ $checkValidation = (!$checkValidation)?false:true; /* Show Warning msg or let FormIt run this snippet */ $htmlTag = (!$htmlTag)?'p':$htmlTag; /* The HTML Tag used for the warning container */ $showIntro = (!$showIntro)?true:false; /* Show the intro text */ $delimiter = (!$delimiter)?', ':$delimiter; /* Delimiter between labels */ $ucfirst = (!$ucfirst)?false:true; /* Uppercase first charater of the label */ $errorClass = (!$errorClass)?'error':$errorClass; /* Error class */ $introClass = (!$introClass)?'contactUs':$introClass; /* Intro class */ if(!$checkValidation) { /* Let FormIt run this to see if a validation failed */ /* Create global variables */ if(!$modx->FormItTmpArray) { $modx->FormItTmpArray = array(); } /* Create variable that contains all the pre-defined validators */ if(!$modx->FormItTmpValidate) { $validateTmp = explode(',',$validate); $tmpValidate = array(); foreach($validateTmp as $k => $v) { $v = trim(ltrim($v),' '); $keyd = explode(':',$v); $tmpValidate[$keyd[0]] = array(); foreach($keyd as $ka => $va) { if($keyd[0] != $ka) { $tmpValidate[$keyd[0]][$ka] = $va; } } } $modx->FormItTmpValidate = $tmpValidate; unset($tmpValidate); } /* Check if the validation failed and pass on variables */ if ($validator->errors[$key] && $validator->errors[$key] != "") { $modx->FormItTmpArray[] = array( "error" => strip_tags($validator->errors[$key]), "key" => $key, "value" => $value, "validation" => $modx->FormItTmpValidate[$key] ); return false; } else { return true; } } else { /* Show warning message or an intro text */ if(count($modx->FormItTmpArray)==0) { /* Visitor first view, show intro text if enabled */ if($showIntro) { $html = '<'.$htmlTag.' class="'.$introClass.'">'.$modx->lexicon('formit.formIntro').'</'.$htmlTag.'>'; return $html; } else { return; } } else { /* Validator failed: Show warnings */ $validateWarning = array(); $tmp = array(); $i = 1; foreach($modx->FormItTmpArray as $k => $v) { /* Loop occored validation warnings */ if(in_array("isNumber",$v["validation"])) { /* isNumber */ if($v["value"] != "" AND !is_numeric($v["value"])) { $validateWarning["isNumber"] = $modx->lexicon('formit.formErrorsNumberNotValid'); $tmp["isNumber"][] = $v["key"]; } } if(in_array("email",$v["validation"])) { /* email */ if($v["value"] != "") { $validateWarning["email"] = $modx->lexicon('formit.formErrorsEmailNotValid'); } } if(in_array("required",$v["validation"])) { /* required */ if($v["value"] == "") { $tmp["required"][] = $v["key"]; $validateWarning["required"] = $modx->lexicon('formit.formErrorsMissing'); } } $i++; } $html = '<'.$htmlTag.' class="'.$errorClass.'"><span></span>'.$modx->lexicon('formit.formErrors'); $i = 0; foreach($validateWarning as $k => $v) { if($i > 0) { $html .= "<br/><br/>"; } if($k == "required" OR $k == "isNumber") { $aTmp = ""; foreach($tmp[$k] as $ki => $vi) { $vi = ($ucfirst)?ucfirst($vi):$vi; if($ki == 0) { $aTmp .= $vi; } elseif((count($tmp[$k])-1) == $ki) { $aTmp .= ' '.$modx->lexicon('formit.formAndWord').' '.$vi; } else { $aTmp .= $delimiter.$vi; } } $html .= str_replace("[[+value]]",$aTmp,$v); } else { $html .= $v; } $i++; } $html .= '</'.$htmlTag.'>'; return $html; unset($tm,$dl,$modx->FormItTmpArray,$modx->FormItTmpValidate); } }
formit.formAndWord = and formit.formErrors = <strong>Some errors were detected in your form</strong><br/> formit.formErrorsMissing = The following required field(s) are missing: [[+value]]. formit.formIntro = Your personal intro message, use below bla bla bla formit.formErrorsEmailNotValid = The email address is not valid formit.formErrorsNumberNotValid = The specified number is not valid: [[+value]].
p.s. the lexicons where translated. Please update this to better Denglish.
&validate=`contact_name:required:FormItValidator:stripTags:minLength=^4^,
&validate=`contact_name:required:minLength=^4^:FormItValidator:stripTags,
if(in_array("minLength",$v["validation"])) { /* minLength */ $tmp = explode('=',$v["key"]); $val = $tmp[1]; $val = str_replace("^","",$val); $val = (int)$val; if(count($v["value"]) != $val) { $tmp["required"][] = $tmp[0]; $validateWarning["minLength"] = $modx->lexicon('formit.formErrorsMinLength'); } }
&validate=`contact_name:required:minLength=^4^:FormItValidator=^Contactnaam^:stripTags,
$vi = str_replace("_"," ",$vi);