Thursday 29 December 2016

File Type Validation using Java Script



Step 1:
Create a File browse item.
Step 2:
Create a button to submit the page. Give the Action when Clicked as Defined by Dynamic Action.
Step 3:
Create a Dynamic Action with execution of JavaScript as
function validateEstimation() {
            var IsValid = true;
    var estimate_file=$("#P13_ESTIMATE_FILE").val().trim();
       
            if (IsValid) {

              var exist_file= "";
            if($("#P13_DOWNLOAD_FILE").length > 0) exist_file = $("#P13_DOWNLOAD_FILE").html();
               if (estimate_file == "" && exist_file == "") {
                                                            IsValid = false;
                    alert("Please select estimate file.");
               }
               else if (estimate_file !="")
               {
                   estimate_file = estimate_file.substring(estimate_file.lastIndexOf("."));
                   //alert(estimate_file);
                   var allowedFormats = "|.pdf|.xls|.doc|.xlsx|.docx|";
                   if (allowedFormats.indexOf("|" + estimate_file + "|") == -1) {
                       IsValid = false;
                       alert("Invalid Estimate file format selected.");
$("#P13_ESTIMATE_FILE").val('');
                   }
               }

                   if (!IsValid) return false;
            }
}


This Java Script function helps to accept .pdf,.xls,.doc,.xlsx,.docx files.

By
A.Arun Kumar

3 comments:

  1. Excellent blog I visit this blog it's really awesome. The important thing is that in this blog content written clearly and understandable. The content of information is very informative.
    Oracle Fusion HCM Online Training
    Oracle Fusion SCM Online Training
    Oracle Fusion Financials Online Training
    Big Data and Hadoop Training In Hyderabad

    ReplyDelete
  2. Such a nice blog, I really like what you write in this blog, I also have some relevant information about if you want more information.

    Big Data and Hadoop Online Training

    ReplyDelete
  3. I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well.

    Spark and Scala Online Training

    ReplyDelete