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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:14:13+00:00 2026-05-23T11:14:13+00:00

$(document).ready(function(){ if($(#field-huima-0-value).val()==” && $(.link-field .form-text).val() ==”) $(#edit-submit).click(function(){ alert(you must at least enter one value!);

  • 0
$(document).ready(function(){ 
    if($("#field-huima-0-value").val()=='' && $(".link-field .form-text").val() =='')
    $("#edit-submit").click(function(){
       alert("you must at least enter one value!"); 
    });
});

field-huima-0-value and .link-field .form-text are two input text boxes id and class.

when the two input text boxes is null. i click the submit button. the alert box shows, then i click ok. the form still be submitted. but now,i want to prevent the form from submitting. so i add the return false; under the alert line. it can prevent the form submitting.but when i type a value into one input boxes of the them, when click the button. it still shows the alert box.

  • 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-23T11:14:13+00:00Added an answer on May 23, 2026 at 11:14 am

    I think you code needs some modifications, kindly check this out:

    $(document).ready(function() { 
      $("#edit-submit").click(function() {
         if(!$("#field-huima-0-value").val() && !$(".link-field .form-text").val()) {
             alert("you must at least enter one value!"); 
             return false;
         }
         return true;
      });    
    }); 
    

    this code will attach the check function to the click event of your submit button, and only returns false if the check didn’t succeed.

    Update: I’ve updated the above code ans tested it, and now working fine, also I’ve made you a sample to test this code, kindly follow this link: http://jsfiddle.net/6egtW/1/

    let me know what happened.

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

Sidebar

Related Questions

<script type=text/javascript> $(document).ready(function () { $(#list > li).click(function(){ var $val = $(this).text(); $(#hi).attr('value',$val); });
$(document).ready(function() { // #login-box password field $('#password').attr('type', 'text'); $('#password').val('Password'); }); This is supposed to
this code: $(document).ready(function() { $('body').click(function(evt) { if(evt.target.nodeName === 'A' && $(evt.target).hasClass('cross-link')) { $('a[href=#2]').trigger('click'); }
$(document).ready(function() { $('form#search').bind(submit, function(e){ e.preventDefault(); $('#content').html(''); // Define the callback function function getGeo(jsonData) {
$(document).ready(function() { //Check City Value var city_value = parseInt($(#city).val()); if( city_value == 0) {
I have the following code, see below: $(document).ready(function(){ var prefixNumber = $('.numeric').val(); if(prefixNumber.match(????){ prefixNumber.addClass('.field-error');
How to put jquery result in text field. Here is the code: jquery: $(document).ready(function
I am trying this code: <script type=text/javascript> $(document).ready(function() { $('.edit').editable('http://www.example.com/save.php', { indicator : 'Saving...',
I have this JQuery: $(document).ready(function() { $(#generate).click(function() { var texts = []; alert(); $(form
Hi I have some code.. $(document).ready(function() { $(#inputPageName).keyup(function () { var value = $(this).val();

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.