What is vldPersonals?

vldPersonals is a very easy to use dating/social software. It allows you to create a fully functioning & modern dating website in a matter of minutes. If You think it's too complicated - check vldPersonals!
Know more about how You can become a dating website owner

What is vldCrowd?

vldCrowd.com is the biggest unofficial community of vldPersonals owners. It is a place to share ideas and thoughts about Your dating website. It is a place to answer questions and receive answers.
Do You own a vldPersonals license? Don't hesitate and join!

Connect Today

Community members help each other to take their dating websites to the next level. Can You make your vldPersonals website better? Join and find out...

Connect With More Than 700 Dating Website Owners! Sign Up Today
10000 3 11
This post was inspired by Dragon's request.
 
Sometimes it may be useful to set minimum length of the filed. Especially for textareas. This is example for profile editing page. Let's say we want minimum 5 words for every textarea field.
 
Open your lib.account_profile.php, function save_member(), line ~464 (Validate value conditions)
Right after:
PHP

elseif ($field['field_maxlength'] && strlen($field['field_value']) > $field['field_maxlength'])
                        {
                                $TEMPLATE->set_message("error", str_replace("%1%", $field['field_name'], str_replace("%2%", $field['field_maxlength'], ($LANG['profile']['field_too_long']))), 0, 0);
                                return 0;
                        }
 

Add this:
PHP

elseif ($field['field_type'] == 'textarea' && $field['field_required'] && str_word_count($field['field_value']) < 5)
                        {
                                $TEMPLATE->set_message("error", str_replace("%1%", $field['field_name'], str_replace("%2%", 5, ($LANG['profile']['field_too_short']))), 0, 0);
                                return 0;
                        }
 
 

Now we have to add language string to /includes/languages/english/lang.lib.account_profile.php
right below "field_too_long" translation:
PHP

"field_too_short" =>
"\"%1%\" has to contain at least %2% words.",
 

Voila!
 
P.S.: If you still want to count only chars, use strlen function instead of str_word_count.
P.P.S.: That was controlling number of words for textareas in Edit profile page. If you want control words number during registration modify lib.account_register.php page!

Comments

slinky

  • Posted on 12/02/2009 12:30 PM
This works perfectly in 2.5.5 - I just installed it. Not sure if my other comment shows but it's a great hack and you might have problems if you forget to set text fields as "required" if you want this hack to work.

slinky

  • Posted on 12/02/2009 09:52 AM
I got this to work in 2.5.5 - it won't work if your text field is not "required" and there are problems with the required ones too I have found. If you remove the required part it works although it will cycle you through every text field to fill out.

radioact

  • Posted on 11/08/2009 09:50 PM
That was controlling number of words for textareas in Edit profile page. If you want control words number during registration modify lib.account_register.php page

radioact

  • Posted on 11/08/2009 08:54 PM
That is correct, SC. $field['field_required'] checks is that field set Required to Yes, otherwise no sense in checking filed length.

sexcenter

  • Posted on 11/08/2009 05:55 PM
firesgame, is this correct? ($field['field_type'] == 'textarea' && $field['field_required'] && strlen($field['field_value']) < 20)

sexcenter

  • Posted on 11/08/2009 05:45 PM
firesgame, may I ask what is "elseif ($field['field_required'] && ..." Thanks,

rombest

  • Posted on 10/28/2009 11:36 AM
I confirm 2.5.5 does not works

radioact

  • Posted on 10/27/2009 10:26 PM
Firesgame, I've added your 'field_required' amendment, thank you.

Log in to leave a comment