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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:16:27+00:00 2026-06-03T00:16:27+00:00

I have several text input fields in my page, and few radio buttons. Now

  • 0

I have several text input fields in my page, and few radio buttons. Now I need to validate them at client side, before I send them to server side (having server side validation too).

I am validating text inputs using jquery and javascript, but now I am wondering is this really the best way to validate them?

And how is this going to work with radio buttons?

$('form').submit(function() {
    validateForm($(this))
    return false;
});

function validateForm(form) {
    var FirstName=form.find('[name=FirstName]').val();
    if (!FirstName) {
        alert('Etunimi puuttuu');
        return false;
    }
}
  • 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-03T00:16:31+00:00Added an answer on June 3, 2026 at 12:16 am

    If you are just validating to ensure the fields aren’t blank then i would add a class to all text fields like so

    <input type="text" id="Firstname" class="validate" />
    

    then use Jquery to loop over all fields with a class of .validate and check whether any of them are blank. You can then choose how you alert the user.

    $('.validate').each(function(){
    
       if($(this).val().length === 0)
       {
          alert($(this).attr('id')+ " is blank");
       }
    });
    

    for radio buttons you could check like so

    if($('#myRadio').not(':checked'))
    {
       alert('Radio not checked');
    }
    

    by testing the :checked pseudo selector

    Or similarly grouping sets of checkboxes together by assigning a class and then looping over them to test that at least one has been checked.

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

Sidebar

Related Questions

I have a page with several Ajax.InPlaceEditor fields. Some are single line (text input
I have a form that includes several input text fields and a list that's
I have a page with several text inputs and several buttons. When I click
I have several text fields <input class=add type=text> <input class=add type=text> <input class=add type=text>
I have a huge form with at least 200 input fields- text/radio/checkboxes . I
Hi I have several text input boxes, and i have a clear button, they
I have several text fields that are dynamically populated based on user choice from
I have one form with several text fields and one button. When i enter
I have some codes to combine several fields and pass to 1 input field
Quick question about CI. I have a view with a form, several text input

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.