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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:29:53+00:00 2026-06-05T09:29:53+00:00

I have a form to edit a database table that’s populated by setting the

  • 0

I have a form to edit a database table that’s populated by setting the <input value="<?php echo $myvalue?>"> however I’m trying to validate the form and if I erase the field, on form_submit, the value returns as the old $myvalue instead of the "" which I would be wanting to see. I notice in the HTML that the value attribute is still set, which makes some sense, but I’m not sure how any forms check if the input is empty in this case!?

This is my validation function so far.. I haven’t been able to test it completely yet.

$(".my-form").submit( function(e) {
        $('error-desc').hide();
        $('input').removeClass('error');
        $('input[name^=edit]').each( function(){
            if ($(this).val()===""){
            $(this).addClass('error');
            $('error-desc').show();
            }
        });

        $('.add > .item').each( function(){
            var empty = true;
            $(this).find('input').each(function(){
                if ($(this).val() !== ""){
                    empty = false;
                }
            });
            if (!empty){
                $(this).find('input[name^=edit][value=""]').each(function(){
                    $(this).addClass('error');
                    $('error-desc').show();
                });
            }
        });

        if ($('input').hasClass('error')) {
            $('html, body').animate({
                scrollTop: $('.error-details').offset().top
            }, 2000);
            return false;
        } else {
            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-05T09:29:54+00:00Added an answer on June 5, 2026 at 9:29 am

    jQuery’s .val() method should be returning the correct "" if the input is emptied by the user or through javascript regardless of what is in the source.

    If something else is happening instead, you need to provide a jsfiddle with proof as that isn’t how the .val() method works. If the input is empty, .val() will return an empty string.

    Demo: http://jsfiddle.net/eW63x/

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

Sidebar

Related Questions

I have this function to edit all fields that come from the form and
Let's say I have an edit view that is strongly-typed to a table called
We have an MS Access 2007 database with a simple form displaying table data.
Another question by a newbie. I have a php variable that queries the database
Another question by a newbie. I have a php variable that queries the database
I am very new to PHP; ADD.PHP - I have a form that collects
I have a gridview that shows records from a database table. Now, I want
I have a form and on that form there is a table of records.
Say I have two fields in a new or edit form: <%= f.text_field :email
I have a simple form where a user can add, edit, and delete people

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.