Thursday, August 6, 2020

Pass String to JavaScript

In order to pass a string value as parameter to a javascript function using htp.p. I used the below mechanism by enclosing it in 2 single quotes.

         htp.p('<td colspan="1" style="text-align:left"> <input type="text" id="processing_spatial_number_of_changes'||i||'" name="process_sp_number_of_changes" size="5" ' ||
     lv_sp_classname ||' value="" onblur="checkisnumtext(this,''# of Changes in Processing Section'');"  ></td>');

function checkisnumtext(field,text1)
{
  var s_token_num=field.value;
  var isnum = /^\d+$/.test(s_token_num);
     if (! isnum) {
        alert(text1 + " should contain only numeric digits");
        return false;
     }
     else{
      //alert(text1 + " contains only numeric digits");
      return true;
    }  
}
//end function checkisnumtext

No comments:

Post a Comment