Check out the LimeSurvey source code on GitHub!

Numerical Input - maxlength properties

More
6 years 2 months ago #51373 by AkeB0N0
Hello,
we would like to create a numerical input question which is has to be width 22 characters. But, Limesurvey doesn't accept more than 20 characters.

As you can see the following code, the maxsize properties controlling the input value which has been set as 20. So, my question is, if we change that properties, the script can continue the work?
function do_numerical($ia)
{
    global $clang;
 
    if ($ia[8] == 'Y')
    {
        $checkconditionFunction = "checkconditions";
    }
    else
    {
        $checkconditionFunction = "noop_checkconditions";
    }
    $qidattributes=getQuestionAttributes($ia[0],$ia[4]);
    if (trim($qidattributes['prefix'])!='') {
        $prefix=$qidattributes['prefix'];
    }
    else
    {
        $prefix = '';
    }
    if (trim($qidattributes['suffix'])!='') {
        $suffix=$qidattributes['suffix'];
    }
    else
    {
        $suffix = '';
    }
    if (trim($qidattributes['maximum_chars'])!='')
    {
        $maxsize=$qidattributes['maximum_chars'];
        if ($maxsize>20)
        {
            $maxsize=20;
        }
    }
    else
    {
        $maxsize=20;  // The field length for numerical fields is 20
    }
    if (trim($qidattributes['text_input_width'])!='')
    {
        $tiwidth=$qidattributes['text_input_width'];
    }
    else
    {
        $tiwidth=10;
    }
    // --> START NEW FEATURE - SAVE
    $answer = "<p class=\"question\">\n\t$prefix\n\t<input class=\"text\" type=\"text\" size=\"$tiwidth\" name=\"$ia[1]\" "
    . "id=\"answer{$ia[1]}\" value=\"{$_SESSION[$ia[1]]}\" alt=\"".$clang->gT('Answer')."\" onkeypress=\"return goodchars(event,'0123456789.')\" onchange='$checkconditionFunction(this.value, this.name, this.type)'"
    . "maxlength=\"$maxsize\" />\n\t$suffix\n</p>\n";
    if ($qidattributes['hide_tip']==0)
    {
        $answer .= "<p class=\"tip\">".$clang->gT('Only numbers may be entered in this field')."</p>\n";
    }

Please Log in to join the conversation.

More
6 years 2 months ago #51593 by Mazi
Just test. Worst case is that you enter a huge number like 3205739502459237502752 which can't be stored at the database.


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form