Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Mandatory Fields & Next Button

Hello everyone,

I have a problem in regard to programming mandatory open question fields. As the study takes place online, it is not possible to use the "form_base".

Probably simple but I cannot figure it out: In some open questions, participants need to enter their age or write down opinions.

1) However, the answers need to be mandatory, so that the participants cannot skip the questions.

2) Only a mouseclick on the "next button" is allowed. What code do I need to use, so that the question is not skipped, when "Enter" is pressed? As in one question participants need to list some words, I am afraid that they will press "Enter" in order to skip to the next line. Unfortunately, then the next question would be already shown and the former one not properly answered.

Thank you a lot for your help!



  • FabFab
    edited April 2023

    Hi @anna_st,

    I'm not experienced with this, but you can achieve it by using the inline_html object (information on how to use it here: and searching the internet for information about HTML forms).

    In that form, type something like:

    <textarea name='response' rows='10' cols='50'></textarea>
    <input type='submit' value='submit'>

    This creates a text box with 10 rows and 50 columns, and a button that says "submit".

    The participant will be able to type text in that box, including pressing ENTER, and the response will only be taken once the "Submit" button is pressed.

    Note taht by naming the textarea "response", I'm actually defining the variable from which you can then retrieve the response. To illustrate it, you can insert a feedback object right after and set it up as follows:

    You can edit the form in anyway you like (just look up for information on HTML forms).

    I attach a small example:

    Note that HTML forms will only work if you run your task in a browser (I assume you are, since you posted this in the OSWeb forum).

    Hope this helps!


    Buy Me A Coffee

  • Hello @Fab,

    thank you so much for your response! This has helped me a lot.

    Is there a similar code for the form_base function for when the experiment is conducted in person/offline?

    And do you have an idea what code I could use, so that participants cannot skip any questions before actually replying to them?

    Have a great weekend!


  • Hi @anna_st,

    If you don't want participants to skip a response without providing some response, you should place the form insde a seuqence inside a loop, set the loop to repeat say 10 times, and set a "break if" condition so that the loop is interrupted when a response has been produced. For this, you need to use code in Javascript to detect when a response has been detected, then set a specific variable to a certain value that you then test in the "break if" condition. If you have several questions in your task, you'll need to reset that variable between questions.

    That will still allow participants to juste press the space bar once as an asnwer, though. If you want to use a more demanding check, you can do so developping the code as you see fit.

    Second, concerning running the task in the browser offline. Running in the experiment in the browser is geared toward running it on a server (e.g., in connection witrh JATOS) for the data to be handled. Running it through the browser from OS will run the task but it will not save the data. So, to save the data, you have to write some code in Javascript that will do so. Here is one way to do so:

    At the beginning of the experiment, we set the following variables:

    // The array to store the participant responses
    vars.participantResponses = [];

    Right after a form, we need to collect the response and append it to previously collected data (you'll need to go through the ode and adapt it dpeending on your needs, as you'd need to use this type of code after any response collection if you want to include it in the data saved at the end).

    // Function to add a new response object to the participantResponses array
    function appendResponse(responseObj) {
    // Replace this with the actual data collected during the trial
    const trialData = { id: 1, subject: vars.subject_nr, response: vars.response, reactionTime: vars.response_time};
    // Add the trial data to the participantResponses array
    if (vars.response!="") {

    At the end of the experiment, you'll need to include some code saveing the data into a text file (the task will prompt the user to indicate where the file should be saved).

    // Function to save CSV data as a local file
    function arrayToCSV(data) {
    const header = Object.keys(data[0]).join(",");
    const csvRows = => Object.values(row).join(","));
    const csvContent = [header, ...csvRows].join("\n");
    return csvContent;
    function saveCSVFile(data, filename = "participant"+vars.subject_nr+"_data.csv") {
    const csvData = arrayToCSV(data);
    const csvBlob = new Blob([csvData], { type: "text/csv;charset=utf-8;" });
    const a = document.createElement("a");
    const url = URL.createObjectURL(csvBlob);
    a.href = url; = filename; = "none";
    setTimeout(() => {
    }, 100);
    // Save the participantResponses array as a CSV file

    I include an example with two form questions:

    I don't recommend running the experiment through the browser in the lab unless really necessary, and the code above may, depending on how many trials you're using and the nature of your tas, slow things down and consume memory. OSWeb is really designed to work with some server solution (e.g., JATOS).

    Have a look at the example and adapt the code as you require (Javascript is a language of its own, independent from Open Sesame, so each user should edit based on their needs and goals).

    Hope this helps.


    Buy Me A Coffee

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games