observeEvent with showModal

I wish to display a dialog saying "No Barcode Scanned" when user clicks Save Data button when its textbox of Barcode is empty (i.e input$Barcode). But below does not display that dialog. Can anyone help? Thanks.

  if (is.null(input$Barcode)) {   
      title = "No Barcode Scanned",
      "Please scan a barcode in the textbox.",
      easyClose = TRUE
    jqui_draggable(selector = '.modal-content')
  } else {
   ###  blah blah  do something


This would stop evaluating before you check if it's empty (if it's empty)

hmm.. remove that above link will crash the application when its textbox is empty, and when Save data button is pressed.

Then if req guarantees your barcode is populated, remove the null check after it and the message to user about it not being populated ?

but what I need is to show that dialog box of empty barcode when it is empty and user presses the button.

or alternativesly, if that text box is empty, I want to disable that button. I try that, but it does not work too.

textInput("Barcode", h4("Scan and press Save Data button"))

# server.R
output$SaveData <- renderUI({
    bsModal("modalSaveData", "Save Data", "save_tmp_data", size = "small",wellPanel(
      h3('Are you sure you want to save the data?'),
      actionButton("save_data", "Save"),
      actionButton("cancel_data", "Cancel")
    actionButton('save_tmp_data','Save Data')

  if (input$Barcode == '') {

A proper reprex would reduce the upfront costs on any would be helper (like myself) to run your code

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.