Question

Create an external JavaScript file/code and then write a function that displays an alert box. This...

Create an external JavaScript file/code and then write a function that displays an alert box. This box will display when the user clicks the submit button to submit the information typed in the form, so be sure the alert box contains an appropriate message. please use the OnClick event handler for your form's submit button.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

Created three fields using html forms and then when clicking a submit button calling a function which is present in java script. in that function showing alert that thank you for registering username

java script code has written externally and embedded in the html file

Html code:

<html>
   <head>
       <title>User Regisration Form</title>

       <script type="text/javascript" src="sub.js"></script> <!-- embedding external javascript code-->

   </head>

   <body style="background-color:darkslategray;color:white">

       <h1 style="margin-left:550px;margin-top:150px;">User Registration Form</h1>
      
       <form> <!-- form which contains three fields name username and password -->

       <div style="width:500px;margin-left:580px;margin-top:60px">

               Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" id="user"><br><br>

               Username:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text"><br><br>

               Password:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="password"><br><br>

               <input type="submit" style="margin-top:20px;margin-left:110px;" onclick="datasubmit()">
              
               <!-- when clicking submit button calling datasubmit() function in java script-->

       </div>

       </form>

   </body>

</html>

Java script code:

function datasubmit()
   {
   var username=document.getElementById("user").value;
   alert("Thank You for registering " + username);
}

Code and Output Screenshots:


Note : if you have any queries please post a comment thanks a lot..always available to help you..

Add a comment
Know the answer?
Add Answer to:
Create an external JavaScript file/code and then write a function that displays an alert box. This...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In an external JavaScript file, you need to create two global variables for the Quarter name...

    In an external JavaScript file, you need to create two global variables for the Quarter name array and the Sales amount array. Create an anonymous function and connect it to the onclick event of the Add to Array button that adds the values from the fields (Quarter and Sales) to the respective arrays. Create an anonymous function and connect it to the onclick event of Display Sales button displays the contents of the arrays, displays the sum of all the...

  • 2. Write a JavaScript to create a. Alert Dialog Box b. Confirmation Dialog Box c. Prompt...

    2. Write a JavaScript to create a. Alert Dialog Box b. Confirmation Dialog Box c. Prompt Dialog box 3. Write a JavaScript to Change an image when a user holds down the mouse button. 4. Write a JavaScript to display all the cookies set on your machine. 5. Write a JavaScript to disable right click on the page

  • HELP! Event Handling- Develop an event handler to handle onclick Form Validation event when a user...

    HELP! Event Handling- Develop an event handler to handle onclick Form Validation event when a user clicks the submit button on the Survey Form. The event handler should validate the following: o The Name tesxt box should contain only Alphabets. o The Address text boxes should contain only appropriate numeric, alphabet or alphanumeric characters o Make sure at least two checkboxes are checked. o Make sure a radio button option is selected. o The Email Address should be valid. Validate...

  • Develop the Change Calculator application In this exercise, you’ll create an application that displays the minimum...

    Develop the Change Calculator application In this exercise, you’ll create an application that displays the minimum number of quarters, dimes, nickels, and pennies that make up the number of cents specified by the user. Without the use of a JavaScript Library (for coins). 1.      Open the HTML and JavaScript files below: 2.      In the JavaScript file, note that three functions are supplied. The $ function. The start of a calculateChange function. And an onload event handler that attaches the calculateChange...

  • In this lab assignment, you'll write code that parses an email address and formats the ci and zip...

    Using Microsoft Visual Studio C# In this lab assignment, you'll write code that parses an email address and formats the ci and zip code portion of an address. String Handling Email: [email protected] Parse City: Fresno State: ca Zp code: 93722 Format ให้ 2 Parsed String Formatted String User name: anne Domain name: murach.comm City, State, Zip: Fresno, CA 93722 OK OK Create a new Windows Forms Application named StringHandling and build the form as shown above. 1. Add code to...

  • Could you please help me write a Javascript code that will show a smiley face picture...

    Could you please help me write a Javascript code that will show a smiley face picture when I click the button. The picture should not display until the button is pressed. Here is my attempt at the code. It does not work. Please keep the code as simple as you can as I am new to coding. Please also use the <div> tag if possible, onclick and use the getElementById. Thank you <html> <body> <img id="exampleImage" src="smileyFace.png" /> <button onclick="pushButton()">Try...

  • Write a C# code for a Sales Calculator: Note: You cannot use the foreach loop in...

    Write a C# code for a Sales Calculator: Note: You cannot use the foreach loop in any part of this program! sales.txt file: 1189.55, 1207.00, 1348.27, 1456.88, 1198.34, 1128.55, 1172.37, 1498.55, 1163.29 The application should have controls described as follows: • A button that reads Get Sales. If the user clicks this button, the application should call a method named ProcesSalesFile. ProcessSalesFile Method: accepts no arguments and does not return anything The ProcessSalesFile Method will do the following: o Open...

  • Write a C# code for a Sales Calculator: Note: You cannot use the foreach loop in any part of this...

    Write a C# code for a Sales Calculator: Note: You cannot use the foreach loop in any part of this program! sales.txt file: 1189.55, 1207.00, 1348.27, 1456.88, 1198.34, 1128.55, 1172.37, 1498.55, 1163.29 The application should have controls described as follows: • A button that reads Get Sales. If the user clicks this button, the application should call a method named ProcesSalesFile. ProcessSalesFile Method: accepts no arguments and does not return anything The ProcessSalesFile Method will do the following: o Open...

  • a) Write JavaScript code (Q4.js) that is executed when the place order button is pressed and...

    a) Write JavaScript code (Q4.js) that is executed when the place order button is pressed and it calculates the cost of each item (based on quantity specified) entered the online form and the overall total cost. The results should be displayed on the same page under the form submission button All JavaScript code must be external. If any fields are left blank or do not contain a number, an alert box should display an appropriate error message upon form submission...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT