4 Replies Latest reply on Dec 17, 2015 10:07 AM by dragonsen

    How to copy multiline text into new single line text box

    dragonsen

      I have a form that has several fields. My question revolves around three fields in my form. One of them is a multiline textbox ("Purpose") that is required. One is a text box for amount ("AmountR1"). The last is a single line text box ("DescriptionR1"). My goal is that if Purpose has data, AmountR1 is not 0, & DescriptionR1 is blank then Purpose needs to copy over to DescriptionR1. Due to the flow of the form, the script is in the validation of AmountR1.

      //Set the source and destination vars
      
      var Orig = this.getField("Purpose");
          Orig = Orig.replace(/[\n\r]/g, '<br>');
      var MText = Orig.split("<br>");
      
      var source = MText.join();
      
           source = source.replace(",", " ");
      
      var destination = this.getField("DescriptionR1");
      
      var AmtR = this.getField("AmountR1");
      
      //See if destination is empty and if so, insert source value
      
      if ((destination.value == '' || destination.value == null) && (source.value != '' || source.value != null) && (AmtR.value != "" || AmtR.value != null)){
      
           destination.value = source.value;
      
      }
      
      
      

       

      However, my code is just putting "Null" in the DestinationR1 field. Any help would be appreciated.