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 7939441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:05:59+00:00 2026-06-03T23:05:59+00:00

I am trying to create my own basic form validation without having to resort

  • 0

I am trying to create my own basic form validation without having to resort to heavy, one-size-fits-all plugins and I have written the following code. It doesn’t seem to matter how often I rewrite it and start over, I can’t seem to get it to work.

The idea is that the script checks the form to see if all the fields have been completed and if so it removes the disabled attribute from the submit button.

The Function:-

function checkForm(){
$('#contact :input').each(function(){
  if($(this).attr('value') == null){
     var checked = false; 
    } else {
     var checked = true;
    }
})
if (checked == true){
   alert('all filled in');
   //remove disabled attribute from button  
} else {
    alert('not completed');
    //add disabled attribute to button
}

}

And the code that calls the function:-

$('#contact :input').blur(function(){
     if ($(this).val() <= ''){
        $(this).next('.error').show();
    } else {
        $(this).next('.error').hide();
        checkForm();
    }
})

I’ve been messing about with this all day and am struggling to find an answer via Google.

  • 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-03T23:06:01+00:00Added an answer on June 3, 2026 at 11:06 pm
    function checkForm(){
      var checked = true;
      $('#contact :input').each(function(){
        if(!$.trim($(this).val()).length) checked = false;
      })
      if (checked){
       alert('all filled in');
       //remove disabled attribute from button  
      } else {
        alert('not completed');
        //add disabled attribute to button
      }
    }
    

    And to call the function

    $('#contact :input').on('blur', function(){
         if (!$.trim($(this).val()).length){
            $(this).next('.error').show();
        } else {
            $(this).next('.error').hide();
            checkForm();
        }
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create my own plugin. But I'm having trouble getting things right.
Im learning basic C on my own and trying to create a poker client.
I am trying to create my own torrent tracker but dont know how to
I'm trying to create my own templated List class as a practice excercise. I
I'm trying to create my own template for a List class as a learning
I am trying to create my own next and previous arrows in a fancybox
I am trying to create my own plist file to be used in my
I am trying to create my own little MVC system, its working very well,
Right now I'm trying to create my own tiny MVC (just for practice and
Ok, I've been trying to create my own GKSession object and the delegate method

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.