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

  • Home
  • SEARCH
  • 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 9229353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:33:01+00:00 2026-06-18T05:33:01+00:00

i am working on project using php,html,javascript. i am using on blur and onsubmit

  • 0

i am working on project using php,html,javascript. i am using on blur and onsubmit both the functions to provide dynamic kind of feel for errors. the following logic is working in every file except for this one .
The form functions like onsubmit and onblur are not working , i used an alert also to check but its not being called could someone please check and tell me where i am going wrong

<script language="Javascript">
//the flags are used to check if all the fields are filled and none is empty
var flag1;
var flag2;
var flag3;

function test(){

    alert("fn called");
    return true;


}
function fun1() 
{
var donated_date=document.forms["myform"]["donated_date"];
if(donated_date==null||donated_date=="")
{   
    document.getElementById('ddate').innerHTML = "Choose the date of your last donation " ;
    document.getElementById('ddate').style.display = "block" ;
    flag1=false;
    return false;

}
document.getElementById('ddate').style.display = "none" ;
flag1=true;
return true;

}
function fun2()
{   
var location=document.forms["myform"]["location"];
if(location==null||location==""||!isNaN(location))
{
    document.getElementById('loc').innerHTML = "Mention the location of your last donation " ;
    document.getElementById('loc').style.display = "block" ;


    flag2=false;
    return false;
}
document.getElementById('loc').style.display = "none" ;
flag2=true;
return true;

function fun3()
{   

var hospital_name=document.forms["myform"]["hospital_name"];

if(hospital_name==null||hospital_name==""||!isNaN(hospital_name))
{
    document.getElementById('hname').innerHTML = "Mention the Hospital Name where you last donated " ;
    document.getElementById('hname').style.display = "block" ;
    flag3=false;
    return false;
}
document.getElementById('hname').style.display = "none" ;
flag3=true;
return true;

}

function validate()
{
alert("hello");

}
</script>
          <form name="myform" method="post" action="o.php"  onsubmit="return validate()">
          <table width="94%" cellpadding="3px" class=" lastDonatedblood_table" cellspacing="0" style="border: 1px solid #CCCCCC;margin: -18px 0 14px 6px;width: 98.5%;">
            <tr>
                    <td style="text-align:left;">Donated Date:</td>
                    <td style="text-align:left;">
<input type="text" name="donated_date" id="donated_date"  onblur="return test();" style="width:300px;"/>
                        <div id="ddate"></div>
                    </td>

                </tr>
                <tr>
                    <td style="text-align:left;">Location:</td>
                    <td style="text-align:left;"><textarea  name="location" id="location"  onblur="return fun2();" style="width:300px;"></textarea></td>
                </tr>
                <center></center>
                <tr>
                    <td style="text-align:left;">Hospital Name:</td>
                    <td style="text-align:left;"><input type="text" name="hospital_name" id="hospital_name"  onblur="return fun3();" style="width:300px;"/></td>
                </tr>
                <center><div id="hname"></div></center>
                <tr>
                    <td style="text-align:left;">Type of Donation:</td>
                    <td style="text-align:left;">
                        <select title="" name="donationtype" id="donationtype"  style="width:317px;">

               <option value="blood">Blood</option> 
               <option value="platelets">Platelets</option>
               </select>
                    </td>
                </tr>
                <tr >
                  <td colspan="2">
                     <input name="submit" id="submit" value="ADD" type="submit" style="margin-top:5px; margin-left:185px; font-size:14px; width:100px;">
                  </td>
                </tr>
            </table>
            </form>
  • 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-18T05:33:02+00:00Added an answer on June 18, 2026 at 5:33 am

    you are missing closing curly bracket (function close) for fun2(),

    function fun2()
    {   
    var location=document.forms["myform"]["location"];
    if(location==null||location==""||!isNaN(location))
    {
        document.getElementById('loc').innerHTML = "Mention the location of your last donation " ;
        document.getElementById('loc').style.display = "block" ;
    
    
        flag2=false;
        return false;
    }
    document.getElementById('loc').style.display = "none" ;
    flag2=true;
    return true;
    } <-- added closing curly bracket here 
    

    Check in console and you will get the error

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

Sidebar

Related Questions

I am currently working on a php/html/javascript project and am doing ajax post to
I am currently working on a php/html/javascript project. I have a form where when
I'm working on a php project based on Joomla! and i'm using Aptana. I'm
I'm working on a PHP + HTML + jQuery project. And there are quite
I'm working on a Chess-based hobby project with HTML/CSS/PHP. I wasn't familiar with chess
I'm working on a project in PHP using Netbeans IDE which is best for
I am working on a php/HTML web project and I have a form which
I'm working on a little project, basically I have some text on my PHP/HTML
I'm working on a small project, where I'm using the codeigniter php framework, but
Working on a project using Entity Framework (4.3.1.0). I'm trying to figure out how

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.