Question

For this discussion, you will be working with regular expressions. Please create a regular expression that...

For this discussion, you will be working with regular expressions. Please create a regular expression that requires passwords to begin with an uppercase letter, followed by five lowercase letters, followed by a one-digit number (0-9), and ending with one symbol (@, $, %, or &).

You may use the index.htm file included with this discussion to test your regular expression. Note that the index.htm file contains HTML and JavaScript. To test your regular expression, simply assign your regular expression to the "regularExpression" variable in the <script> section of index.htm, save the file, launch index.htm in a browser, and verify that only valid passwords are marked as acceptable.

Note that you do not have to submit the index.htm file for this discussion. Just reply to the thread and include your regular expression.


Content of index.htm:

<!DOCTYPE html>
<html>
<head>
    <title>Discussion 8</title>
</head>
<body>
    <h1>Password Validation</h1>
    <p>
      Enter a password that begins with an uppercase letter, followed by five
      lowercase letters, followed by a one-digit number (0-9), and ending with one symbol (@, $,
      %, or &).
    </p>
    </ul>
    <input type="text" id="pass"><br/>
    <input type="button" id="submit" value="Submit">
    <br/><br/>
    <p id="result"></p>

    <script>
      var password = document.getElementById("pass");
      var submit = document.getElementById("submit");
      var result = document.getElementById("result");

      var input = "";
      var regularExpression = /./; // Replace with your regular expression

      function validate() {
        input = password.value;
        password.value = "";

        if (regularExpression.test(input)) {
          result.innerHTML = "Your password is acceptable.";
        } else {
          result.innerHTML = "Your password is not valid.";
        }
      }

      if (submit.addEventListener) {
        submit.addEventListener("click", validate, false);
      } else if (submit.attachEvent) {
        submit.attachEvent("onclick", validate);
      }
    </script>
</body>
</html>

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

Solution

var regularExpression = /[A-Z][a-z]{5}[0-9][@|$|*|&]/;

or

var regularExpression = /[A-Z][a-z][a-z][a-z][a-z][a-z][0-9][@|$|*|&]/;

Explanation

[A-Z] ------------> begins with an uppercase letter.

[a-z]   ------------> five lowercase letter with an lowercase letter.

[0-9] ------------> number 0-9

[@|$|*|&]  ------------> Any of Special Symbols

Add a comment
Know the answer?
Add Answer to:
For this discussion, you will be working with regular expressions. Please create a regular expression that...
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
  • This question relates to Javascript. Could you please show me why my code is not working?...

    This question relates to Javascript. Could you please show me why my code is not working? I want to create 2 text boxes and have the user enter something into both of them. If the text entered into both boxes is identical the a green message is made visible. If the boxes are different a red message is made visable. Please keep it simple because I am new to javascript. <html> <head>               <title></title>        <script>...

  • LANGUAGE JAVASCRIPT, PHP Need help with PHP and ajax code. The user needs to login but,...

    LANGUAGE JAVASCRIPT, PHP Need help with PHP and ajax code. The user needs to login but, I keep getting an error that I coded "Wrong username and password!" ***PLEASE DONT GIVE ME A NEW CODE THAT IS NOWHERE NEAR THE CODE I SUBMITTED***** PLEASE LOOK AT THE CODE AND SEE ANY ISSUES login.html <!DOCTYPE html> <html> <head> <title>login popup</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <style type="text/css"> body { background-color: white; } </style> </head> <body> <center> <h1 style="text-align: center;"> Login </h1> <form>             Login ID:...

  • NEED HELP with HTML with Javascript embedding for form validation project below. I have my code...

    NEED HELP with HTML with Javascript embedding for form validation project below. I have my code below but I'm stuck with validation. If anyone can fix it, I'd really appreciate. ****************************************************************************** CODE: <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html> <head> <title>Nice</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script> var textFromTextArea; function getWords(){ var text =...

  • <!DOCTYPE html> <html> <head> <!-- JavaScript 6th Edition Chapter 4 Hands-on Project 4-3 Author: Da...

    <!DOCTYPE html> <html> <head> <!-- JavaScript 6th Edition Chapter 4 Hands-on Project 4-3 Author: Date:    Filename: index.htm --> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Hands-on Project 4-3</title> <link rel="stylesheet" href="styles.css" /> <script src="modernizr.custom.05819.js"></script> </head> <body> <header> <h1> Hands-on Project 4-3 </h1> </header> <article> <div id="results"> <p id="resultsExpl"></p> <ul> <li id="item1"></li> <li id="item2"></li> <li id="item3"></li> <li id="item4"></li> <li id="item5"></li> </ul> </div> <form> <fieldset> <label for="placeBox" id="placeLabel"> Type the name of a place, then click Submit: </label> <input type="text" id="placeBox"...

  • How can I connect the html forms to php --> mysql database <!DOCTYPE html> <html lang="en">...

    How can I connect the html forms to php --> mysql database <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <h2> <center> Average: </h2> <h3> <center> Rate the following: </h2> <h3> <center> Rating Criteria: <br> Developing (0-5), Competent (6-10), Accomplished (10-15); </h3> <center> Judge Name: <input type="text" id="judge"> <br> <br> <center> 1. Articulate requirements and design of the project: <input type="text" id="num1"> <br> <br> 2. Plan the solution and implement the project: <input type="text" id="num2"> <br> <br> 3....

  • URGENT HELP NEEDED: JQuery. PLEASE POST SCREEN SHOTS Task 1: Downloading jQuery Right-click the link to...

    URGENT HELP NEEDED: JQuery. PLEASE POST SCREEN SHOTS Task 1: Downloading jQuery Right-click the link to download the uncompressed latest version of jQuery Copy the jQuery.x.x.x.js file in the folder and specified as source file. Task 2: Download and install HTML-Kit 1. Navigate to htmlkit.com. 2. Click Download HTML-Kit 292. After it downloads, launch HKSetup.exe. Choose Full installation (the default) Uncheck Yes, download and install HTML-Kit Tools Trial. 6. Click Next>Finish. Task 3: Creating a Simple jQuery Application Launch HTML-Kit....

  • Unit 1 Programming Assignment Follow the directions for each of the following questions. Answer the question...

    Unit 1 Programming Assignment Follow the directions for each of the following questions. Answer the question or provide the code in a space below the question. 1. Write the complete script tag set for a script whose line statement is document.write(“Hello, world.”); 2. Build a complete HTML document and include the answer to the previous question such that the page executes the script as the page loads. Open the document in your browser to test the results. 3. Add a...

  • Modify current code to complete the following: Current code: Validate a Web IP address which will...

    Modify current code to complete the following: Current code: Validate a Web IP address which will accept the following positive examples: 1.1.1.1 192.0.0.255 255.255.255.255 The IP address comprises four parts each of which is one to three digits, with each part separated by a DOT or period. To match a single digit, or two digits, or three digits, you will need to use the curly braces to specify the minimum and maximum number of digits desired. digits, you will need...

  • Add comments to it by filling in the blank comments numbers 1 through 32. (The first...

    Add comments to it by filling in the blank comments numbers 1 through 32. (The first few comments are HTML comments, not JavaScript comments, and are bracketed according to <!- this is an HTML comment>.) <!DOCTYPE html> <html> <body onload="handleFormAction()"> <h2>Form handling example in JavaScript</h2> <h3>(Or, John Doe meets Robbie Robot)</h3> <h4>Instructions: Fill in the form. Then fill in comments 1 through 23 in the JavaScript code!</h4> <form target="_blank" action= > <!- 1: replace this placeholder HTML comment with a...

  • Modify this code to store the form elements as variables and display them on the page...

    Modify this code to store the form elements as variables and display them on the page in an HTML table. <!DOCTYPE html> <html> <head> <script> function getValues() {     var result = ""; result += "First Name: " + document.forms["myForm"]["fname"].value + "<br>"; result += "Last Name: " + document.forms["myForm"]["lname"].value + "<br>"; result += "Address: " + document.forms["myForm"]["address"].value + "<br>"; result += "City: " + document.forms["myForm"]["city"].value + "<br>"; result += "State: " + document.forms["myForm"]["state"].value + "<br>"; document.getElementById("output").innerHTML = result; } </script>...

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