This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 2

How to enforce users to enter specific values in number fields ?


  1. Leopard
    Member

    Hi ,

    i have a field of type number ( number of samples ) and i want the users to enter only integer values between 1 and 25 . if the user enters more than 25 , error message arises
    ( please enter a value between 1 and 25 ).

    Thanks ,

    Posted 15 years ago #
  2. redityo

    Hi,

    Try to edit your "includes/post-functions.php" file and go to around line 240 ~ 242, you will see these code :

    if($validation_result !== true){
    	$error_elements[$element_id] = $validation_result;
    }

    then put these code exactly bellow that lie

    if (empty($error_elements[$element_id]) &&
    		$element_id == 1 &&
    		$form_id == 1 &&
    	!($element_data >= 1 && $element_data <= 25)) {
    	$error_elements[$element_id] = " Enter value from 1 - 25";
    }

    I set that code for form 1 and element number with id 1, make sure you change those Id's with yours


    MachForm Support

    Posted 15 years ago #
  3. Leopard
    Member

    Thanks redityo for this great support

    i have implemented the code and it's working ..

    Thanks :)

    Posted 15 years ago #

RSS feed for this topic

Reply