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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:49:47+00:00 2026-05-23T07:49:47+00:00

I am trying detect in ajax what is the field that is empty. (

  • 0

I am trying detect in ajax what is the field that is empty. (echo $field; >>> output is radios)

This if (!data.livre && data.livre == "radios") { checks if data.livre is not true (that is working) and now i want to check if the echo is radios or not. If is radios i showed to the user: empty radios

function check($form) {
            $fields = array("radios", "age");
            foreach($fields as $field) {
                if(empty($form[$field])) {
                    echo $field;
                    return false;
                }
            }
            return true;
    }

    $data = array();
    $data['livre'] = $val-> check($form);
    echo json_encode($data);

JSON output:

radios{"livre":false}

js

        success: function(data) {
             if (!data.livre && data.livre == "radios") { //problem here
                $("#msgbox1").fadeTo(200, 0.1, function() {
                 $(this).html('empty radios').addClass('messageboxerror1').fadeTo(900, 1);      
                });
            }
        }

EDIT: What is the best way to identify if the field that is empty is radios or age ?

thanks

  • 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-05-23T07:49:47+00:00Added an answer on May 23, 2026 at 7:49 am

    If the result can be that only radios or age or none of both can be empty then you have to edit your check to !data.livres || data.livres == "radios" || data.livres == "age". It will then print the message if your json output is the following:

    {livres: false}
    

    or

    {livres: "radios"}
    

    or

    {livres: "age"}
    

    Edit: Changes according to your comment

    if (!data.livre) { //problem here
      // Do whatever you want to do when livres is false
    } else if (data.livre == "radios") {
      // Do whatever you want to do when livres is "radios"
    } else if (data.livre == "age") {
      // Do whatever you want to do when livres is "age"
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to detect which web in sharepoint that the user is looking
I'm trying to detect any touch on the iPhone's UIStatusBar but its not working.
I'm trying to detect an incoming call in the Lync client . This is
I'm trying to detect the center of a circle. I try to do this
Im trying to write a quick plugin that will load some AJAX content into
In trying to detect a right mouse click with jquery, I noticed that the
I'm trying to detect the size of the screen I'm starting emacs on, and
I'm trying to detect when the onresize event ends in a browser. If I
I'm trying to detect Use after free() bugs, otherwise known as Dangling pointers. I
I'm trying to detect the position of the browser's scrollbar with JavaScript to decide

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.