Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8940171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:58:40+00:00 2026-06-15T10:58:40+00:00

I tried this, Its not working. I want to do following things: While clicking

  • 0

I tried this, Its not working.

I want to do following things:

While clicking on submit button the profilePic should be validate.
profilePic must not be null and it must accept only one of the

gif|png|jpg|jpeg|pjpeg

file.

I also want to add maximum size for uploading.

 $("#basicprofile").bind("submit", function() {
            $("#profilePic").validate({
                rules: {
                    field: {
                        required: true,
                        accept: "gif|png|jpg|jpeg|pjpeg"
                    }
                }
            });
        });


 <s:form action="basicprofile" method="post" enctype="multipart/form-data" 
  id="basicprofile">
       <s:file name="profilePic"  id="profilePic" label="Profile Picture" />
       <s:submit />
 </s:form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:58:41+00:00Added an answer on June 15, 2026 at 10:58 am
    $(document).ready(function() {
    
        $("#basicprofile").validate({
            rules: {
                profilePic: {
                    required: true,
                    accept: "gif|png|jpg|jpeg|pjpeg"                
                }
            },
    
            messages: {
                profilePic: {
                    required: "Empty file",
                    accept: "Wrong format!!"
                }                  
            },
    
            errorPlacement: function(error, element) {
                $("#error-messages").html(error); // error container
            }
    
        });
    
    });
    

    You can check that the field is Filled and file have correct format in browser, but check filessize is hard problem. You have to do it with AJAX, and use the filesize headers sent by the browser to the server on the POST request.

    Yahoo’s UI Library has a tool to help with this. YUI Uploader

    Example (without check file size): http://jsfiddle.net/burlak/U36JS/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This page should display a Google ad. I Tried everything but it's not working.
i have tried this code to redirect a php page.but it s not working
Don't dismiss this as a newbie question! It's not, I'm not, I've tried everything,
This is some code that I picked up which I tried to implement. Its
I tried this here: http://jsfiddle.net/92HXT/1/ but it does not work. It only works if
EDIT I tried both of the suggestions below, but it's still not working... It
I want to use regex in ng-repeat. I have tried the following code but
I am using jQuery autocomplete and its working fine, now I want to store
I've tried searching for this but it's pretty difficult to put into words. Basically,
I have tried making a fiddle for this, but it's been too difficult to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.