Error messages with Radio buttons

This sample code shows how to display error messages on kintone records. In this particular example, the user must choose a value for the radio button field other than the default value - otherwise an error will show up on the field and the record.

Sample Image


Sample Code

(function() {
    "use strict";

    var RADIOBUTTON = "Radio_Button";
    var RADIO_VALUE = "N/A";

    // Run code when saving a record
    var ev = ['app.record.create.submit', 'app.record.index.edit.submit', 'app.record.edit.submit'];, function(event) {

        // Get record data
        var record = event.record;
        var selection = record[RADIOBUTTON]['value'];
        var params = {
        return kintone.api('/k/v1/app/form/fields', 'GET', params).then(function(resp) {
            // Obtain label name of Radio button field
            var name =[RADIOBUTTON].label;
            if (selection === RADIO_VALUE) {
                var errMessage = "Please select other than \"" + selection + "\"";
                // Show message underneath field
                record[RADIOBUTTON]['error'] = errMessage;
                // Show message at top of record
                event.error = errMessage + " for the field \"" + name + "\"";
            return event;


Refer to the Tutorial page, on how to add scripts to your app.

Was this article helpful?
0 out of 0 found this helpful
Please sign in to leave a comment.