We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38547
    • 98 Posts
    I have a weird problem, if I set the minLength at 3 or more the form submits no problem even if just one character is entered. However as soon as its set at 4 or above it works fine, I am using the most recent formit snippet the required field validation works a treat wondered if anyone has any clues what the issue might be.

    The following is called from a chunk and this is everything it contains
     [[!+fi.validation_error_message]]
    [[+errors]]
       [[!FormIt?
                 &hooks=`email`
                 &emailTpl=`sentEmailTpl`
                 &emailSubject=`Message from Website`
                 &emailTo=`[email protected]`
                 &validate=`contact_name:required:minLength=^2^,
    	      contact_email:email:required,
    	      contact_message:required:stripTags` 
               ]]
           
             
    
    	<div id="contact-area">
    			
    			<form method="post" action="[[~[[*id]]]]">
                             [[!+fi.error.contact_name]]
    		<label for="contact_name">Name </label>              
    <input id="contact_name" name="contact_name" size="30" class="required" minlength="2" value="[[!+fi.contact_name]] " />
    	
    				<label for="contact_email">E-Mail </label><em>(required)</em><br />
                                    [[!+fi.error.contact_email]]
    <input id="contact_email" name="contact_email" size="30"  class="required email" value="[[!+fi.contact_email]]" />
    				
    				<label for="contact_message">Your comment </label><em>(required)</em><br />
                                    [[!+fi.error.contact_message]]
    <textarea id="contact_message" name="contact_message" cols="70" rows="7" class="required">[[!+fi.contact_message]]</textarea>
    
    				<input type="submit" name="submit" value="Submit" class="submit-button" />
    			</form>
    			
    			
    		
    		</div>
    [ed. note: ianman last edited this post 11 years, 1 month ago.]
    • I wonder if this could have anything to do with using mb_string functions?
      $v = $this->config['use_multibyte'] ? mb_strlen($value,$this->config['encoding']) : strlen($value);
      
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 38547
        • 98 Posts
        Quote from: sottwell at Mar 09, 2013, 02:44 AM
        I wonder if this could have anything to do with using mb_string functions?
        $v = $this->config['use_multibyte'] ? mb_strlen($value,$this->config['encoding']) : strlen($value);
        
        It may well be that its on a basic shared cpanel hosting so no access to php.ini anyway I have turned on the math hook so the minLength is not going to make a lot of difference anyway in the grand scheme of things.

        Many thanks

        Ian