Form validation for file inputs

Hi,
Does anybody know if Spry can do a file input validation? I'm
interested at least to check if the file is empty or not.
Thanks

is this a JavaScript question or a Java queston ?

Similar Messages

  • Parameters used for file input

    Hi,
    PARAMETERS : P_FNAME LIKE RLGRAP-FILENAME OBLIGATORY
    PARAMETERS : P_FNAME LIKE IBIPPARMS-PATH OBLIGATORY
    PARAMETERS : P_HFILE LIKE FILENAME-FILEINTERN OBLIGATORY
    PARAMETERS : P_NAME TYPE APQI-GROUPID.
    The above are the various ways of decalring the parameters for file input... can u tell me what is the difference between them & the situations or condition when, which one has to be used ??
    Regards,
    - Hello SAP

    Hi,
    I am assuming you are using the parameters to upload/download a file.
    Here is what they will do for you. Let us see the following file name parameter.
    <i>PARAMETERS : P_FNAME LIKE RLGRAP-FILENAME OBLIGATORY</i>
    Defining the parameter this way will help you in using the obsolete function modules of WS_DOWNLOAD, WS_UPLOAD as their interface requires the filename to be defined this way. But the new replacement for them GUI_DOWNLOAD and GUI_DOWNLOAD defined the filename as a string. Also F4 function modules used for browsing through desktop directories for a file like KD_GET_FILENAME_ON_F4 also use the parameter of this type.
    So, if you are using a function module like the ones above, then you are better of with this parameter.
    Let us see this definition.
    <i>PARAMETERS : P_FNAME LIKE IBIPPARMS-PATH OBLIGATORY</i>
    This is no different from the one above, so it makes no difference.
    Next.
    <i>PARAMETERS : P_HFILE LIKE FILENAME-FILEINTERN OBLIGATORY</i>
    This is typically used for a logical file name, not a physical filename and path. What a logical filename does is that it allows you to define logically define filenames and use them in your programs at the same time giving you(or your network team) the flexibility to change the directory structure. When they change the directory structure, all you have to do is to change your logical path definition, rather than changing every single program that uses the path. FILE is the tcode for this area. Length of this is just 60 and so it may not be sufficient for the filename and path. But if you are using it as a logical file name, then it is useful when using function modules like FILE_GET_NAME which will read in a logical file name and give you the string containing the physical path and file name.
    Now the last one.
    <i>PARAMETERS : P_NAME TYPE APQI-GROUPID.</i>
    This is not at relevant for files. This is used in batch input and this is the name of the batch input session. It is 12 characters long.
    Hope this helps, if not please let us know.
    Srinivas

  • Server side validation for file type with cffil sent via cfmail problem

    Hello;
    I have a small app that I need to allow users to be able to use a form, and send me and email with a file attachment. I have it working nicely, I included file manipulation into the validation process of the form and required form fields. The problem I'm having, is this. I'm trying to create and instance where if they try and upload lets say a pdf, it throws and error: "You are trying to upload the wrong file, please try again we only accept bla bla bla" Problem is, even if I'm uploading the proper file, it's rejecting it and deleting it. Can someone help me fix this? I've tried a number of different ways and can't seem to get this to go off properly. I am posting some of the code. There is a ton, so I'm posting the main parts so you get the idea and see my variables.
    <!--- Declairing my variables and setting up form validation--->
    <cfparam name="FORM.descript" type="string" default=""/>
    <cfparam name="FORM.attachment_1" type="string" default=""/>
    <cfset arrErrors = ArrayNew( 1 ) />
    <cfset showForm = true>
    <cfif structKeyExists(form, "sendcomments")>
    <cfif NOT len(trim(FORM.name))>
    <cfset ArrayAppend(arrErrors,"Your Full Name!<br>") />
    </cfif>
    <!--- This is where the file error control is as you can see how the name is validated, the file will be dealt with in a similar maner--->
    <cfif NOT Len(Trim(FORM.attachment_1))>
    <cfset ArrayAppend(arrErrors,"You didn't attach a file!<br>") />
    <cfelseif ArrayLen( arrErrors )>
    <cftry>
    <cffile action="DELETE" file="#FORM.resume#"/>
    <cfcatch>
    <!--- File delete error. --->
    </cfcatch>
    </cftry>
    <cfelse>
    <!--- no errors with the file upload so lets upload it--->
    <cftry>
    <cfset request.AcceptImage="image/gif,image/jpg,image/jpeg,image/pjpeg,image/x-png">
    <cffile action="upload"
                     filefield="attachment_1"
                     accept="#request.AcceptImage#"
                     destination="c:\websites\187914Kg3\uploads\"
                     nameconflict="Makeunique">
    <!---
    Now that we have the file uploaded, let's
    check the file extension. I find this to be
    better than checking the MIME type as that
    can be inaccurate (so can this, but at least
    it doesn't throw a ColdFusion error).
    --->
    <cfif NOT ListFindNoCase("request.AcceptImage",CFFILE.ServerFileExt)>
    <cfset ArrayAppend(arrErrors,"Only JPEG, GIF, and PNG file formats are accepted!<br>") />
    <!---
    Since this was not an acceptable file,
    let's delete the one that was uploaded.
    --->
    <cftry>
    <cffile action="DELETE" file="#CFFILE.ServerDirectory#\#CFFILE.ServerFile#"/>
    <cfcatch>
    <!--- File Delete Error. --->
    </cfcatch>
    </cftry>
    </cfif>
    <!--- This is the code that is causing my problem. The above code is saying everything is not the proper file and rejecting it all--->
    Can anyone help me out. I can make more of this code available if needed. Like i said, there's a lot and I didn't want to dump it all out, this is the section creating the problem. There are no errors at this time, just rejecting all file types.
    thank you.

    It appears you are comparing your content_length with 1MB.
    1KB: 1024 bytes
    1MB: 1024*1024 bytes
    Let us use max allowable size of 25KB here and amend the second half of our code.
    <!--- Set max allowable file size in KB at the top --->
    <cfset maxFileSize = 25>
          <!--- Check if file is an image file of acceptable size --->
          <cfif (#reFindNoCase("gif|jpg|jpeg|pjpeg|png",myResult.clientFileExt, 1)# EQ 1) AND (#myResult.FileSize# LTE (#maxFileSize#*1024))>
                <!--- Retain if right file type and size --->
                <p>
                Your file <strong>#myResult.clientFile#</strong> has been uploaded successfully!<br />
                <a href="yourTemplate.cfm">Back</a></p>
                <!--- Otherwise if wrong type --->
          <cfelseif #reFindNoCase("gif|jpg|jpeg|pjpeg|png",myResult.clientFileExt, 1)# NEQ 1>
                <p>
                You are trying to upload a <strong>#myResult.clientFileExt#</strong> file, please try again. We only accept <strong>gif, jpg, jpeg, and png</strong>.
                </p>
                <!--- Delete unacceptable file and show form to user to try again--->  
                <cffile action="delete"  file="#svrFile#" />
                      <form method="post" action=#cgi.script_name# 
                      name="uploadForm" enctype="multipart/form-data">
                      <input name="attachment_1" type="file">
                      <br>
                      <input name="submit" type="submit" value="Try again!">
                </form>
                <!--- Or size too large --->
          <cfelseif #myResult.FileSize# GT (#maxFileSize#*1024)>
                <p>
                Your file was too large (<strong>#numberFormat(myResult.fileSize/1024, "____.__")# KB</strong>). Please try a smaller file!
                </p>
                <!--- Delete file and show form--->
                <cffile action="delete"  file="#svrFile#" />
                      <form method="post" action=#cgi.script_name# 
                      name="uploadForm" enctype="multipart/form-data">
                      <input name="attachment_1" type="file">
                      <br>
                      <input name="submit" type="submit" value="Try again!">
                </form>
          </cfif>
    </cfif>        <!--- Closes the cfif tag which started from the first half --->
    </cfoutput><!--- ditto --->

  • Validation of file input

    hi gurus ,
    can it is possible to validate the file input (cust-name) is available in r/3 syetem or in sender system.
    can i do these type of validation in xi ?
    warm regards.

    Pawan,
    Refer this -Re: Table lookup instead of fixed value mapping
    raj,

  • Form validation for sql submission

    is there a way i can take the fields of my forms and replace any instance of ' with /' so that it can be submitted to my Postgres database successfully? i've come across a basic javascript function that replaced "a" with "z" and i tried modifing that, but it crashes my browser.
    surely being a common requirement for form submission for database entry, there must be a function written somewhere that handles this
    i know its not strickly java, but its something anyone that has developed in JSP, PHP or whatever must have come across

    is this a JavaScript question or a Java queston ?

  • Q: General : Can workshop test form display a browse icon for file input?

    Hi,
    Is it possible to write a web service which takes in say a license file for validation
    and returns a boolean true if
    valid and false if not valid? Can the workshop test form display a browse icon so
    that I can select the license file
    from my local system? Or do I have to write an html/jsp front-end to the web service
    myself?
    Thanks,
    Sadhana

    Hi Adam,
    Thanks a lot again for answering my question with such a nice
    explanation!
    -Sadhana
    "Adam FitzGerald" <[email protected]> wrote:
    >
    Hi Sadhana,
    Web services have two mechanisms to receive data that are part of the SOAP
    1.1 specification.
    The first mechanism is to pass the data as a parameter to the web service
    operation
    - this only works if the data is text based and can be imbedded in an XML
    SOAP document
    (i.e. it cannot be binary information like images or music not can it be
    complete
    standalone XML documents). We demonstrated this technique in class and it
    is the
    most common way to transmit information.
    The second mechanism is to add the data to the SOAP request as an attachment
    (similar
    to email). This mechanism is not available directly in Workshop but WebLogic
    server
    does provide this capability if you use web service handlers. See the URL
    below for
    more information.
    http://edocs.bea.com/wls/docs70/webserv/design.html#1053805
    There is also a third programmatic solution. You could provide a URL for
    the file
    or document that you want to process as a parameter for the web service
    and then
    the web service could use the java.net API to retreive the document dynamically
    during
    processing. This has obvious preformance and security problems but it might
    be applicable
    in some situations.
    Good luck
    Adam
    "Sadhana Jain" <[email protected]> wrote:
    Hi,
    Is it possible to write a web service which takes in say a license file
    for validation
    and returns a boolean true if
    valid and false if not valid? Can the workshop test form display a browse
    icon so
    that I can select the license file
    from my local system? Or do I have to write an html/jsp front-end to the
    web service
    myself?
    Thanks,
    Sadhana

  • Validator for file upload component is not working !!

    This validator method for a file upload component is throwing a java.lang.NullPointerException.
    public void fileUpload1_validate(FacesContext context, UIComponent component, Object value) {
    long size= fileUpload1.getUploadedFile().getSize();
    if (size>65535){
    throw new ValidatorException(new FacesMessage("Your image is too big!"));
    Any help to solve this problem is very much appreciated.
    Thanks.

    Hi i have a fileUpload in a pop-up and the methods are :
    public void fileUpload1_validate(FacesContext context, UIComponent component, Object value) {
    try {
    com.sun.rave.web.ui.model.UploadedFile uploadedFile = ((Upload)component).getUploadedFile();
    long l_filesize = uploadedFile.getSize();
    if ( l_filesize > 1000000)
    throw new ValidatorException(new FacesMessage("File Size should be less than 1000000 bytes! It is" + l_filesize));
    else {
    String tipo = uploadedFile.getContentType();
    if ( tipo.compareTo("application/word") == -1 )
    if ( tipo.compareTo("application/rtf") == -1 )
    if ( tipo.compareTo("application/pdf") == -1 )
    throw new ValidatorException(new FacesMessage("Error : los tipos de archivo aceptados son PDF, WORD y RTF"));
    } catch (Exception ex) {
    this.mauvaisFichier = true;
    error(ex.getMessage());
    public String botonValidar_action() {
    if ( !this.mauvaisFichier )
    if ( this.fileUpload1.getUploadedFile() != null )
    if ( this.fileUpload1.getUploadedFile().getSize() > 0 )
    try {
    this.getSessionBean1().getComunicacion().setArchivo( new javax.sql.rowset.serial.SerialBlob(this.fileUpload1.getUploadedFile().getBytes() ) );
    this.getSessionBean1().getComunicacion().setTipoArchivo( this.fileUpload1.getUploadedFile().getOriginalName().substring(this.fileUpload1.getUploadedFile().getOriginalName().length() - 3 ) );
    } catch(Exception e){
    e.getMessage();
    return null;
    I have to put a boolean value because the first time, validation code doesn't function ( the method botonValidar_action() is called ) correctly. The error message appears but empty.
    If I try next time then it's ok.
    Thx for any issue.

  • Edit box validation for numeric input from prompt

    Hi
    is there a way to issue an alert for wrong data input in edit box? Say I need only numeric values to be entered.
    Thanks
    Kumar

    Hi Kumar,
    I never tried this one myself, but you could try Venkat's way:
    http://oraclebizint.wordpress.com/2008/01/08/oracle-bi-ee-101332-dashboard-prompt-edit-box-input-validation/
    Good Luck,
    Daan Bakboord

  • On Sales Order form Validation for selection tax category as Form C

    Hi All Experts,
    Please help me out for the Validation on Sales Order Form that if CST (Central Sale Tax) Sales Tax code Selected in the transaction form should not get added (Posted into the system) till the Tax Category in the Tax Tab is not selected with Form C.
    Thanks in advance...
    Arinjay Shah

    hi,
    In sales order,you can manually update transaction category even after adding document,
    Why there is need for validaion,If u requires validation use approval procedure,since it
    can be activated only at header level.
    Use this query to trigger approval procedure
    Select DISTINCT 'True' Where $[RDR12.TransCat] IS NULL OR $[RDR12.TransCat] = ' '
    Jeyakanthan

  • How to check validation for a input field?

    For example, I need to check the validation of a field, if OK, then the field will be inputted, otherwise, there will rise a message, how can I implement that?
    Thanks and best regards,
    Anders

    Hi Andres,
    U can write a code in Request Processing--DO_VALIDATE_INPUT
    DATA: LR_BTADMINH       TYPE REF TO   CL_CRM_BOL_ENTITY.
      LR_BTADMINH  ?= ME->TYPED_CONTEXT->BTADMINH->COLLECTION_WRAPPER->GET_CURRENT( ).
        LV_ZZAFLD000057 = LR_ENTITY->GET_PROPERTY_AS_STRING( 'ZZAFLD000057' ).
    IF  LV_ZZAFLD000057 IS INITIAL.
    DATA: L7_MSG_SERVICE TYPE REF TO CL_BSP_WD_MESSAGE_SERVICE,
              LVSP_MSG_V1  TYPE STRING VALUE 'Spare in Progress'.
        L7_MSG_SERVICE = ME->VIEW_MANAGER->GET_MESSAGE_SERVICE( ).
        L7_MSG_SERVICE->ADD_MESSAGE(
            IV_MSG_TYPE       = 'E'
            IV_MSG_ID         = 'ZBSP'
            IV_MSG_NUMBER     = '008'
            IV_MSG_V1         = LVSP_MSG_V1 ).
    ENDIF.
    Regards,
    Lokesh.

  • Spry textfield validation for alphanumeric input

    Hi,
    How can I set the spry input to the following pattern that I need: only allow alphanumeric.

    You can build your own custom validations with Spry.
    var custom = new Spry.Widget.ValidationTextField("id", "custom", {
         validation: function( value, options ){
              return /[a-z]/gi.test( value ); // your validation
    Related reading:  http://labs.adobe.com/technologies/spry/articles/textfield_overview/index.html and http://labs.adobe.com/technologies/spry/samples/validationwidgets/TextfieldValidationSampl e.html

  • Smart form issue for range input

    Hi all,
    i have print out five 5 po . each po in new form
    i.e every po has to start in new page
    i have created a smart form
    loop at header .
    wa = header
    ssf... fm module
    exporting wa
    tables item details
    call function fm_name...
    endloop.
    whats happening is when i execute the program i am getting a pop up window i click on preview , it prints the first p o  and then when i click back agian i see the pop up window and again i have to select print preview then i see 2 po and again back button print preview to see 3 po
    i want to click print preview once and i want to see all 5 po's
    first po and new po in new page
    let me know how to achieve this
    Thanks

    Hi
    I can do it in scripts right
    open form
    loop at itab.
    start form
    write form
    end form
    endloop.
    close form
    Iam looking something like this in smartforms
    Thanks

  • Form validation from within composer - how to lock down admin forms??

    Hello we have many space admin level users who have the privilege to add content and remove it from their pages as they see fit, however when modifying pages from inside webcenter composer there is no validation on user input / error checking. This causes many problems with users entering things improperly, or even causing bugs (such as with content presenter - if you remove a file from UCM without removing it from the "add a file" template it will break the page).
    So my question is - how do I start adding form validation to all of these screens (such as those little wrenches in composer for a task flow, or customizable layout component)? Is there a way to customize form validation for all admin screens (space - manage all, app - administration, and composer screens)?
    Thanks,
    j

    Here is the custom validation script of your drop-down.
    Make sure you tick the option to commit the selected value immediately:
         var sNewSel = event.value;
         switch (sNewSel) {
           case "ProductNo1":
             this.getField("ItemDescription").value = "blah, blah";
             this.getField("Size").value = "blah, blah";
             this.getField("UnitPrice").value = "blah, blah";
             break;
         case "ProductNo2":
             this.getField("ItemDescription").value = "blah, blah";
             this.getField("Size").value = "blah, blah";
             this.getField("UnitPrice").value = "blah, blah";
             break;
         case "ProductNo3":
            this.getField("ItemDescription").value = "blah, blah";
            this.getField("Size").value = "blah, blah";
             this.getField("UnitPrice").value = "blah, blah";
             break;
         //etc.
    You will need to replace "ProductNoX" in the script with whatever your product numbers are in the drop down.
    You can also read MarkWalsh's script in this thread:
    http://forums.adobe.com/message/5578038#5578038
    I hope this helps.

  • Is there a way to bypass the form Validation

    I'm getting really upset with the Coldfusion built-in form validation for any HTML formfield ending by _date , _required, _time and so on...
    My application proposes to the users to create some Properties for an object and later on to modify the values for all these properties.
    I've got a piece of code building dynamically some form fields named just like the properties (by a simple cfloop on a DB query getting the property list).
    And a registering page to records the new value in the DB.
    But it crashes onto the classical "
    Form entries are incomplete or invalid.
    I can't control what the users set as property name (one of them was Checklist_required).
    Is there any way to prevent this error by disabling this auto validation ?
    (I'd like to avoid having to rename any field dynamically created and rename any forms variables before registering them on the DB : it's just NO WAY for me to rename the properties created by the users)

    Fober1, that's not how it works.  It's pretty much the ultimate example of the disjoint between how HTML forms work and how the naive CFML Cfform / cfinput design wished they work.
    When a request is being processed by the coldfusion server, it just looks at the list of FORM (POST) variable names (whether it came from cfform or not; URL/GET params are exempt), and for those with certain suffixes (_date, _required, etc.), and it assumes their existence is intended to request validation another field without that suffix.  It doesn't actually know or care whether form submission, nor the HTML rendered in the user's browser, actually came from "cfform" or "cfinput".   The composition of the request that comes in (when a user clicks on "submit", or a hacker uses any tool imaginable) is out of the server's hands.  The cfform code is not used during form submission processing, because the receiving template (the form action="this_one.cfm") doesn't even have to be the same template that has the cfform in it. There could be multiple conflicting cfforms directing users to request the same template on a single site, with or without the validation, even without considering what a whole other person might decide to send to your server.
    The fact that it can work as intended for a typical user is irrelevant, because the purpose of validation is to deal with the atypical situation.  A malicious or merely mischievous user that wanted to circumvent the validation would simply modify a copy of the page to leave out the "validation request" fields.    For the developer to truly validate the input, additional code must be written, making the feature not only inadequate, but a complete waste of time.  There absolutely should be a way to disable it at worst; Ideally, it would be taken out of coldfusion completely.  It's not only useless, it's a security risk, wooing programmers to write code that doesn't do what they think it does.
    The error message it gives isn't so great, either, and it's a pity that it can't show more than one validation message at a time, either.  If more than one input is invalid, you could end up going through one round after another of submit + back button.
    edit: I forgot to add the other important reason that this feature should never have existed: It is a nuisance to everyone else who doesn't want to use it at all, too!  Those suffixes simply couldn't have been a worse choice, colliding with probably thousands of peoples' variable names.  Why not "*_cfval_date" "*_cfval_time" etc?

  • Form validation before signing

    I have a requirement to validate the data on the form before signing the form. So when i click on a signature field, i want to validate the form data and throw an error message. If there are errors, i do not want to display the signature popup. I am not able to suppress the signature popup. I get the error message popup and right after that Signature window pops up. Is there a way to suppress it if validation fails?

    shagil wrote:
    From your jsp call a Servlet which can do validation for the input.1) "before submission"
    2) you probably mean "HTML form generated by JSP", not "JSP". The latter would be forwarding, which wouldn't be useful.

Maybe you are looking for

  • Error while migrating Essbase application

    HI i am on 9.3 trying to migrate an Essbase application from one server to another. But in selection page I could find only one server name in both source and target? Thanks

  • New iMac, can't connect HP 1315xi all-in-one printer

    iMac is Intel Core i3, 27", 3.2 Ghz processor speed - OS 10.6.4. I've tried to install from disk several times, but can't get the printer driver installed. I Receive a message that the printer is 'currently being used by the user'''', you may not be

  • IDVD 09 and Aperture 3 not open

    When I try to open idvd or Aperture 3 with X 10.6 I get the error message: iDVD cannot be opened because of a problem, check with the developer to make sure IDVD works with this version of Mac OS X. Be sure to install any available updates to the app

  • Using Oracle Sequence

    I am using sequence to generate Id in table. I need the generated value in program to inster that value in another table. right now i am selecting value from "select <seq>.nextval from dual" is this right way or there is other better way of doing thi

  • Help please: Panasonic MiniDV Digital (Model: PV-GS59)

    I have just purchased the camera above. When I plug it into my G4 (running 10.4) nothing happens. It does not mount and it does not show up in iMovie HD. However it does show up under computer profile. Can anyone please help? Thanks in advance!