Avatar

Make a text field become a required field depending on a condition

Ngoc Chu

Hi all, 

I am a beginner of Kintone. My issue is describe below and hope to have your support.

I create a form in which there is a Radio button field and there are 4 options to select, let's call them (1), (2), (3), (4). I followed the tutorial on this website and can customize the form like this (utilize JavaScript):
Once click on (4) with the value is 'Other' > A text field 'Detail' shows up > The user can fill out this text field.

What I would like to do now is that once the text field (Detail) comes up, is there anyway to set it as required field?

Or can we make a warning when saving the form in case the text field is left blank?

(I have tried to set the text field (Detail) as required one but obviously if the user does not chose option (4) > The text field does not show up > Unable to save the form as it is set as required field)

Really hope to get your support and your idea. Thank you very much.

Ngoc Chu

Follow 2 followers
1

2 comments

Avatar
Sean Tachibana 1 vote

Hello Ngoc Chu,

By using each submit events on kintone,
you can check the field value when saving the record.

Also, you may cancel the saving process by outputting the error by
returning the event object with the settings of value to the fields
or the records error property.

Record Create Event:
https://developer.kintone.io/hc/en-us/articles/213149077-Record-Create-Event


kintone.events.on(["app.record.create.submit","app.record.edit.submit"], function(e) {

var button = e.record.radiobutton.value;
var text = e.record.text.value;

if(button === "other" && !text){
e.record.text.error = "REQUIRED";
}

return e;
});

※please match the field codes or the criteria of if and other processors
with the appropriately made app.

Hopefully, this helps.

Sean

1
Comment actions Permalink
Avatar
Ngoc Chu 1 vote

Dear Sean, 

Thank you very much for your reply. I've got the idea but need to try and test several times. It takes time a bit for a non-technical background person like me. Your support means a lot, really. I'll inform the result once I've done.

Once a again, thank you very much.

Ngoc Chu

1
Comment actions Permalink