Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Search Results (Searched for: validation)

  • mapage
  • mapage's Avatar
28 Jul 2023 13:24
@Joffm, thanks a lot for this reply.
What you did is exactly what I need :). Where shall I insert this validation ? In the condition area or in the Regex one ? 

Initially I thought this should be done through the script, as the description of the post was mentioning this, but you are right, I could not find any references to a check format on the script so.... I must be somewhere else..

Regarding the forum, you are fully right also but as the subject field has a nbchar limitation, I had to find something...

And thanks to you and all the comments and judgment on my questions, the way I write, what I ask... each post helps me to be a better newby :).
Cheers
  • Joffm
  • Joffm's Avatar
28 Jul 2023 11:16 - 28 Jul 2023 11:25
Hi,
this is a typical case of validation.
Like Q1_Y001_X002.NAOK le 10 AND Q1_Y001_X003.NAOK  le Q1_Y001_X002.NAOK
for all rows.
Or if you insert a drop-down into AnswerB maybe like this
(is_empty(Q1_SQ001_AnswerC) OR is_numeric(Q1_SQ001_AnswerC)) and (Q1_SQ001_AnswerC.NAOK le Q1_SQ001_AnswerB.NAOK)
for all rows.
 

And the script?
It is to insert a drop-down into column coded "AnswerA".
So not really related to your question.
I do not see an issue here.
 

At the end there are the array(numbers).
You already asked about this and @tpartner provided a very flexible solution.

I am quite lost with the search tool of the forum

So am I.
But even you are part of the problem.
With your topic "Is it possible to setup a Table(text) question as follow ?"
Who do you think will find this if he searchs for the validation / limitation of an entered number?

Joffm




 
  • sbgmedia
  • sbgmedia's Avatar
24 Jul 2023 16:43 - 24 Jul 2023 16:46
Please help us help you and fill where relevant:
Your LimeSurvey version: Version 5.3.31+220815
Own server or LimeSurvey hosting: Own server
Survey theme/template:
==================
I am trying to connect to the Limesurvey API. I have enabled it and can access it in my local test environment, however, when i upload my application online and run it, I get an error :The remote server returned an error: (403) Forbidden.Following is my code:
Code:
 Imports System.IO
Imports System.Net
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq
Public Class _Default
    Inherits System.Web.UI.Page
 
    Public Class JsnRPCclient
        Private id As Integer = 0
        Public Property URL As String
        Public Property Method As String
        Public Property Parameters As JObject
        Public Property Response1 As JsonRPCresponse
 
        Public Sub New()
            Parameters = New JObject()
            Response1 = Nothing
        End Sub
 
        Public Sub New(ByVal URL As String)
            Me.URL = URL
            Parameters = New JObject()
            Response1 = Nothing
        End Sub
 
        Public Function Post() As String
 
            Dim jobject As JObject = New JObject()
            jobject.Add(New JProperty("jsonrpc", "2.0"))
            jobject.Add(New JProperty("id", System.Threading.Interlocked.Increment(id)))
            jobject.Add(New JProperty("method", Method))
            jobject.Add(New JProperty("params", Parameters))
            Dim PostData As String = JsonConvert.SerializeObject(jobject)
            Dim encoding As UTF8Encoding = New UTF8Encoding()
            Dim bytes As Byte() = encoding.GetBytes(PostData)
            Dim requestn As HttpWebRequest = CType(WebRequest.Create(URL), HttpWebRequest)
            requestn.Method = "POST"
            requestn.ContentType = "application/json"
            requestn.KeepAlive = True
            requestn.ContentLength = bytes.Length
            Dim writeStream As Stream = requestn.GetRequestStream()
            writeStream.Write(bytes, 0, bytes.Length)
            writeStream.Close()
            Dim response As HttpWebResponse = CType(requestn.GetResponse(), HttpWebResponse)
            Dim responseStream As Stream = response.GetResponseStream()
            Dim readStream As StreamReader = New StreamReader(responseStream, encoding.UTF8)
            Response1 = New JsonRPCresponse()
            Response1 = JsonConvert.DeserializeObject(Of JsonRPCresponse)(readStream.ReadToEnd())
            Response1.StatusCode = response.StatusCode
            Return Response1.ToString()
 
        End Function
 
        Public Sub ClearParameters()
            Me.Parameters = New JObject()
        End Sub
    End Class
 
    Public Class JsonRPCresponse
        Public Property id As Integer
        Public Property result As Object
        Public Property [error] As String
        Public Property StatusCode As HttpStatusCode
 
        Public Sub New()
        End Sub
 
        Public Overrides Function ToString() As String
            Return "{""id"":" & id.ToString() & ",""result"":""" & result.ToString() & """,""error"":" & [error] & (If((String.IsNullOrEmpty([error])), "null", """" & [error] & """")) & "}"
        End Function
    End Class
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
 
    End Sub
 
    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
 
        'Configure SSL/TLS settings
        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 Or SecurityProtocolType.Tls11 Or SecurityProtocolType.Tls
        ServicePointManager.ServerCertificateValidationCallback = Function(sender2, certificate, chain, sslPolicyErrors) True
 
 
 
 
        Dim Baseurl As String = "https://www.dcsmanagement.com.au/evf/admin/remotecontrol/"
        Dim client As JsnRPCclient = New JsnRPCclient(Baseurl)
        client.Method = "get_session_key"
        client.Parameters.Add("username", "admin")
        client.Parameters.Add("password", "123456")
        client.Post()
 
 
 
        Dim SessionKey As String = client.Response1.result.ToString()
        'Console.WriteLine(SessionKey.ToString)
        TextBox1.Text += SessionKey
        client.ClearParameters()
 
 
        If (client.Response1.StatusCode = System.Net.HttpStatusCode.OK) Then
            client.Method = "list_surveys"
            client.Parameters.Add("sSessionKey", SessionKey)
            client.Post()
        End If
 
        client.ClearParameters()
 
        Dim content As String = client.Response1.result.ToString()
 
        ' Read the response content as a string
 
        ' Dim jsonObject As JObject = JObject.Parse(content)
        Dim jsonArray As JArray = JArray.Parse(content)
        Dim t, i, d As String
 
        For Each item As JObject In jsonArray
            t = item.SelectToken("surveyls_title").ToString
            i = item.SelectToken("sid").ToString
            d = ""
            If t.Contains("<br>") Then
                Dim StringParts() As String = Split(t, "<br>", 3)
                d = StringParts(2).ToString
                t = t.Replace("<br>", " ")
                Literal1.Text += "<tr><td>" &amp; i.ToString &amp; "</td><td>" &amp; t.ToString &amp; "</td><td>" &amp; d.ToString &amp; "</td><tr>"
            ElseIf Not t.Contains("<br>") Then
                d = "---"
                t = t.Replace("<br>", " ")
                Literal1.Text += "<tr><td>" &amp; i.ToString &amp; "</td><td>" &amp; t.ToString &amp; "</td><td>" &amp; d.ToString &amp; "</td><tr>"
            End If
 
        Next
 
        TextBox1.Text += content
    End Sub
End Class


 
  • Joffm
  • Joffm's Avatar
17 Jul 2023 17:05
Replied by Joffm on topic Text box questions

i'm just wondering where I would need to import those lines of code in the question to make them work. 

Did you read the manual about question types?
[url] manual.limesurvey.org/Question_type_-_Sh...28preg_validation.29 [/url]

 

Joffm
 
  • amilcar_pg
  • amilcar_pg's Avatar
05 Jul 2023 16:27
Please help us help you and fill where relevant:
Your LimeSurvey version:  Community Edition   Version 6.1.2+230606 
Own server or LimeSurvey hosting: Own server
Survey theme/template: Vanilla
==================

Hello everyone!

I have a survey with many multiple questions, and It will be distributed via Internet with one of those providers that pay for who is willing to answer it. One of the problems with this kind of approach is that some people just press the same option over and over, just to get their prize. Therefore, I want to avoid this.

My first approach was to use the "Question validation" feature, however, it just pops up a warning, and the person still can just change one answer and keep on. 

So I was willing to create a hidden question with the equation type that returns me 1 if all previous questions on the array have received the same answer, and 0 otherwise. WIth this, I can add a quota that doesn't allow it, and the respondent will be excluded from the survey.

Unfortunately, I haven't been able to program it by myself. I know that it might be something silly, but can anyone help me please?

Thanks in advance for your assistance. I'm attaching a sample survey with 1 similar question.
  • Joffm
  • Joffm's Avatar
30 Jun 2023 16:27
Replied by Joffm on topic Array question
Well, here is my proposal.
Split the question.
Now the second question can be "mandatory" -> no need to validate the drop-downs.
I added the option "none" to the regex. So you get no initial error, but because of the mandatory question it must be filled before submitting.

And I changed the validation tip to two separate tips.
 
 
 


And the lss.
 

File Attachment:

File Name: limesurvey...4471.lss
File Size:42 KB


Joffm
  • coral.sanchez
  • coral.sanchez's Avatar
30 Jun 2023 12:57
Replied by coral.sanchez on topic Array question
Thanks a million, that was a lot of help! You were right about the time picker, I have opted for Igor Escobar's mask library. However, I am still having trouble with the validation equation and validation message. I have attached the .lss file.
I have tried various things but it is not quite there yet.

Keeping in mind: 
X001 for every row should validate answers between 0 and 99
X004 for a valid time

1- I wanted the question to validate when at least one row is completed. (You wouldn't have to answer the whole table for the question to validate, only one row), and I made that work, however, the problem is that as soon as one row is entered correctly, no matter if there is an error in the next row the question will validate.

2- The goal is: 
X001 for every row should validate answers between 0 and 99: validation message when this is not matched 'Introduzca un valor entre 0 y 99 años'
X004 for a valid time: validation message when this is not matched 'Introduzca una hora valida'
Again, it kind of works with some little problems.
- For some reason, what happens now is that X002 and X003 also have to be answered for the message to turn green.
- Is it possible for the validation message to only appear when a wrong answer is typed?

Thanks in advance!
  • holch
  • holch's Avatar
29 Jun 2023 18:35
Replied by holch on topic The CSRF token could not be verified
Cual es tu configuración aqui:

manual.limesurvey.org/Global_settings#Security --> "IFrame embedding allowed"?


Otro link que quizas puede ayudar:
manual.limesurvey.org/Optional_settings#...Validation_in_iFrame
  • Joffm
  • Joffm's Avatar
28 Jun 2023 12:12
Replied by Joffm on topic Array question
Hi,
here your survey back.
I show three options.
1. With a timepicker. To be honest, I do not like it.
It is too large and you have to click and click and click to enter a time.
 

2. With the input mask library of Robin Herbots
[url] github.com/RobinHerbots/Inputmask [/url]
 

3. With the input mask library of Igor Escobar
[url] igorescobar.github.io/jQuery-Mask-Plugin/ [/url]
 

Both with validation
 

 

And here the lss
 

File Attachment:

File Name: limesurvey...6-28.lss
File Size:66 KB



By the way: In my opinion you should remove all dropdowns and let the respondents enter plain numbers that you validate (as in Q1)

Joffm

 
  • robdi123
  • robdi123's Avatar
14 Jun 2023 15:14
Help validating a field was created by robdi123
Please help us help you and fill where relevant:
Your LimeSurvey version: [url=https://10.69.76.49/encuestas/index.php/admin/index#modalSystemInformation]5.4.11[/url]
Own server or LimeSurvey hosting: own server
Survey theme/template: vanilla
==================
Hi, how can i do a validation between a field and bd?
i have a field called Email, the thing is i want to validate that no one else in te past do the survey with the same email.

Thanks!
  • DenisChenu
  • DenisChenu's Avatar
  • DenisChenu
  • DenisChenu's Avatar
12 Jun 2023 10:42
{strpos(join("#",Q1.NAOK)) < 1)} ou {!strpos(join("#",Q1.NAOK)))}

pregmatch devrait passer aussi, à tester {!preg_match('/arbre/i', Q1.NAOK)}

1. La formule est entourée de { }, sinon : tu ne remonte que la variable.
2. .NAOK si la question est masquée
3. LimeSurvey ne connaît pas la différence entre == et === donc on ajoute 1 caractère au début pour ne pas remonter 0.
  • DenisChenu
  • DenisChenu's Avatar
08 Jun 2023 15:17
Replied by DenisChenu on topic Edit integrated pop-up text
Can be updated in javascript

But don't think it's a good idea.

stackoverflow.com/questions/13798313/set...d-validation-message
  • amilcar_pg
  • amilcar_pg's Avatar
06 Jun 2023 23:38
Thanks for your advice Joffm!

I'll do as you suggested.
  • Joffm
  • Joffm's Avatar
06 Jun 2023 22:14
Hi,
the best is to split the group into 6 groups, each with three questions
Text display to display th image
multiple numeric
multiple nuumeric for the ageguess
you may merge the questions with the css classes "no-question" and "no-bottom"
The randomization by randomization group name and by random number stay the same, only on group level.
This way you can limit the ranges by the settings without the need of validation,

Otherwise you have to validate each subquestion, like
RostoHa_study.NAOK<11 and RostoHa_honest.NAOK<11 and... and RostoHa_ageguess.NAOK<100

Joffm
Displaying 136 - 150 out of 182 results.

Lime-years ahead

Online-surveys for every purse and purpose