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

  • Home
  • SEARCH
  • 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 8786387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:36:43+00:00 2026-06-13T21:36:43+00:00

Possible Duplicate: empty field validation in jquery I need to detect if a form

  • 0

Possible Duplicate:
empty field validation in jquery

I need to detect if a form is empty or not. I’ve already client side validation, with mandatory fields and not mandatory, when there is one mandatory field or more, and this is (these are) empty, post button launches client-side validation errors, and this is fine. When they all aren’t mandatory i just need to disable the post button till I insert a value, enabling the post button when i write something. But if i delete the values, i can’t detect if the form is empty or not to re-disable the button!

$('#form .my_field').each(function() {
    $(this).data('oldVal', $(this).val());

    $(this).bind("propertychange keyup input paste change blur", function(event) {
        if ($(this).data('oldVal') != $(this).val()) {
            $('#post_button').button({
                disabled: false
            });
        }
    });
});

with this bind i can detect when i write in a casual form field, but i’ve no clues how to find if every field is clean. I’ve tried many roads, but they lead me to dead end. Maybe is a 10-hours programming issue 🙂 I’ve tried some kind of

 if ($(this).val()=='')

, but for some fields (datapicker for example) does not work (i can have too multiselects —-> :option selected)

I suppose i’ve to bind to the same events to a (if empty set a boolean flag) and check all the boolean flags to determine if they’re all true (or false)..any hints?

  • 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-13T21:36:45+00:00Added an answer on June 13, 2026 at 9:36 pm

    Why not just use an else if?

    Demo: http://jsfiddle.net/dfAtX/

    jQuery:

    $('#form .my_field').each(function() {
        $(this).data('oldVal', $(this).val());
    
        $(this).bind("propertychange keyup input paste change blur", function(event) {
    
            if ($(this).data('oldVal') != $(this).val()) {
                $('#post_button').button({
                    disabled: false
                });
            }
            else if ($(this).val() == $(this).data('oldVal')) { // Don't even bother checking the rest if this doesn't match
                var unchanged = 0;
                $('#form .my_field').each(function() {
                    if ($(this).val() == $(this).data('oldVal')) {
                        unchanged++;
                    }
                });
    
                if (unchanged == $('#form .my_field').length) {
                    $('#post_button').button({
                        disabled: true
                    });
                }
            }
        });
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How do I use jQuery's form.serialize but exclude empty fields I need
Possible Duplicate: Check if inputs are empty using jQuery I have form and textboxes,
Possible Duplicate: How to prevent submitting the HTML form’s input field value if it
Possible Duplicate: C#: Public Fields versus Automatic Properties Duplicate? I think not: This question
Possible Duplicate: Clear 5 empty TDs with Jquery I want to search the DOM
Possible Duplicate: php $_POST array empty upon form submission I am trying to have
Possible Duplicate: php $_POST array empty upon form submission I just make a simple
Possible Duplicate: Create an Empty Data.Frame I need to create an empty data frame
Possible Duplicate: Why isn't String.Empty a constant? I can use but not string.Empty when
Possible Duplicate: Form validation Hey all, I'm just looking for what the correct way

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.