Description in create account

autosurf

Active Member
When a member adds a new account, it does not seem to have control over the description of the site and its length?
How is it possible to add a condition on a minimum number of character information for this field?
Same question for the title with a minimum and maximum value.
Thank you in advance
 

Basti

Administrator
Staff member
Setting a minimum value is not possible. A maximum however works with every template tag. Though not limiting the input, but the output later on the site
in table_top_row.html for example you see
Code:
{$description, length=255}
This limits the length to whatever you want. The same can be applied to every template tag which holds text data
 

autosurf

Active Member
I used the variable "description_length" which is the maximum length of the description to display on many pages.


In the "Join_form.html" file of your template, I replaced the input description by :
Code:
<div class="{$error_style_description}">
<label for="join_description">{$lng->g_description}</label><br />
      <textarea cols="50" rows="5" name="description" id="join_description">{$description}</textarea>
      {$error_description}
  </div><br />
to display the error and supervision


In the "sources / misc / classes.php" file
I added: "$error_description = 0;" line 143 after : "$error_title = 0;"

and i add :
Code:
    if (strlen($TMPL['description']) < $CONF['description_length']) {
      $error_description = 1;
    }
after :
Code:
    if (!$TMPL['title']) {
      $error_title = 1;
    }
i add
Code:
      if ($error_description) {
        $TMPL['error_description'] .= "<br />{$LNG['join_error_description']}{$CONF['description_length']}";
        $TMPL['error_style_description'] = 'join_edit_error';
      }
after
Code:
      if ($error_title) {
        $TMPL['error_title'] .= "<br />{$LNG['join_error_title']}";
        $TMPL['error_style_title'] = 'join_edit_error';
      }
and i have add "$error_description || " in
Code:
if ($error_username || $error_username_duplicate || $error_password || $error_confirm_password || $error_url || $error_url_duplicate || $error_email || $error_title || $error_description || $error_banner_url || $error_captcha || $error_adscaptcha || $error_security_question || $error_plugin_vars) {
I have create phrase in language : join_error_description
example : "The minimum number of characters for the description is:"

It's All ^^
You just do add
Code:
<div class="{$error_style_description}">
<label for="join_description">{$lng->g_description}</label><br />
      <textarea cols="50" rows="5" name="description" id="join_description">{$description}</textarea>
      {$error_description}
  </div><br />
in edit_form.html in your template and in join_form_existing.html for use this control in your editing website

It's All again ^^
 

Basti

Administrator
Staff member
Totally forgot that we have validation methods for this exact purpose lol.

Also note {$CONF['description_length']} is deprecated as of visiolist 1.0 . so don't rely on that.
And all that should be made as a plugin

in join.php we have methods to validate min max or range chars.
- So make a plugin, Name it "CustomValidaion" for example.
- copy any info.php from another plugin and fill the variables in it.
Copy any language folder of a plugin. The english.php in that folder should not contain any lng tags
Plugin should contain also a blank index.htm
- Then you need 3 files. join_process_form.php , join_existing_process_form.php , usercp_edit_process_form.php
- In all 3 files place the following
Code:
array_push($form_validate, validate_range_chars('description', $TMPL['description'], 3, 255, 1));
All error messages and validation happens in the background. In the above code, "3" is the min char, 255 is max, and 1 is required

You can checkout sources/misc/validate.php for other methods
 

autosurf

Active Member
i am not a specialiste to create a plugin but i can try ...

Also, I already tried this method for my first test :
Code:
array_push($form_validate, validate_range_chars('description', $TMPL['description'], 3, 255, 1));
i put this code direct in validate.php ???
but the result "for me" have don't good !!!

So, i do a test with create a plugin with implemented your method ^^
Tomorrow (french hour), i try this ...
 

Basti

Administrator
Staff member
No i told you everything you have to do in my post, there is nothing more to it, just follow the instructions.
 

Basti

Administrator
Staff member
hmm not worked in my tests as well
delete your plugin, ill send you a new one soon
 

autosurf

Active Member
i just download and install this, it's perfect :)
So i come back my developpement in classes.php to use your plugin ...
Thanx very much
 

leonor

Active Member
License Active
ncie Basti, its working for me so far, with one problem.

When i enter a to short Titel i get a message "Value must be between 25 and 255 characters"

But when i enter a to short Description i dont get a message, where i have to add {$lng->validate_range_chars} ?
I cant find it :/

EDIT: i tryed to add description: "required", to join_form.html under title: "required", but thats not help.

Maybe my line in the plugin is wrong?
Code:
array_push($form_validate, validate_range_chars('description', $TMPL['description'], $min, $max, $require));
 

leonor

Active Member
License Active
oh no the Check is working, When its a to short Titel the users get an error, but not for to short Description.


 

cajkan

Active Member
lol why do you force users to write extra junk text ?

What if they want to register with simple brand name and a good slogan as description?

Example:
Titile - Google
Description - Dont click here - you know why!

Im sure lots of curious people will click that :), so i strongly suggest you, give your users freedom
 

leonor

Active Member
License Active
Yes cajkan you are right, i dont like it to get messages from google Webmaster tools that some thing is bad.

I will look for a other solution, but maybe some else need this missing error box fixed.
 

Mark

Administrator
Staff member
hmm I dont see why PHP is needed here at all, if you use jquery validation, simply add minlength="25" to your textarea

<textarea class="required" minlength="25" name="description">

that should work.
 

Mark

Administrator
Staff member
I had some time to look at the template in parabola, and minlength is already in use with jquery validation.

this is what you are after with the 1 new rule added:

Code:
    // validate signup form on keyup and submit
    $("#signupForm").validate({
        rules: {
            u: "required",
            url: "required",
            title: "required",
            username: {
                required: true,
                minlength: 2
            },
            password: {
                required: true,
                minlength: 3
            },
            confirm_password: {
                required: true,
                minlength: 3,
                equalTo: "#join_password"
            },
            email: {
                required: true,
                email: true
            },
            description {
                 minlength: 25,
                 required: true
            }
        },
        messages: {
            u: " *",
            url: " *",
            title: " *",
            username: {
                required: " *",
                minlength: " *"
            },
            password: {
                required: " *",
                minlength: ' <img src="skins/parabola/img/icons/delete.png" alt="{$lng->join_password_match_error}">'
            },
            confirm_password: {
                required: " *",
                minlength: " *",
                equalTo: ""
            },
            email: "*",
            description: {
               minlength: 'DESCRIPTION TOOOOO SHORT I SHOULD USE A NEW LANGUAGE PHRASE FOR THIS!'
               required: '*'
            }
        }
    });
 

Basti

Administrator
Staff member
@leonor, well i just looked at it, and its not like it does not work, rather the html does not allow it to work.
As the form html for the textarea doesnt have the error classes and template tags required to display error - see how title is ( as it was never intended to be validated in whatever way ).

So Marks way is better, but if you need to, in case you use no jquery validation or want backend checks also, copy how it is done on the title html and adjust the template tag names
 
Top