Question

Write a synchronous validator which checks whether a field contains exactly six characters.

Write a synchronous validator which checks whether a field contains exactly six characters.

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

Synchronous validator which checks whether a field contains exactly six characters :-

Save the below code in a .html file and open in a browser.

HTML File :-

<!DOCTYPE html>
<html>

<script>
function checkValue()
{
    var val1 = document.getElementById('val1');
    var message = document.getElementById('error-nwl');
    var goodColor = "#66cc66";
    var badColor = "#ff6666";
   
    if(val1.value.length == 6)
    {
        val1.style.backgroundColor = goodColor;
        message.style.color = goodColor;
        message.innerHTML = "character number ok!"
    }
    else
    {
        val1.style.backgroundColor = badColor;
        message.style.color = badColor;
        message.innerHTML = " you have to enter exactly 6 digits!"
        return;
    }
}
</script>
<body>

<input name="myvalue" placeholder="Enter the value" id="val1" onkeyup="checkValue(); return false;" />
<div id="error-nwl"></div>

</body>
</html>


Output:-

nter the value you have to enter exactly 6 digits!

Add a comment
Know the answer?
Add Answer to:
Write a synchronous validator which checks whether a field contains exactly six characters.
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
  • Write a python program that contains a hardcoded string and checks whether it is a palindrome...

    Write a python program that contains a hardcoded string and checks whether it is a palindrome (the same forwards as backwards). If it is then display “It is a palindrome”, otherwise display “It is not a palindrome”. A hardcoded string is simply a string defined in your program, for example: my_string = “Hello” Some sample palindromes to use are: A car, a man, a maraca Desserts, I stressed Madam, I’m Adam You will need to strip out any punctuation such...

  • Write a program palind.c that reads a message, then checks whether it's palindrome (the letters in...

    Write a program palind.c that reads a message, then checks whether it's palindrome (the letters in the message are the same from left to right as from right to left): Enter a message He lived as a devil, eh? Palindrome Enter a message Madam, I am Adam Not a palindrome Ignore all characters that aren't letters. Use integer variables to keep track of positions in the array. Revise the program in Part I to use a pointer instead of an...

  • Please typed by computer not hand write.. What happens to the rotor of a synchronous motor...

    Please typed by computer not hand write.. What happens to the rotor of a synchronous motor when load torque is applied to the motor? What is the pull-out torque of a synchronous motor? At which angle and relative position (leading or lagging) does the rotor of a synchronous motor pull out of synchronization with respect to the rotating magnetic field? What is the relationship between the pull-out torque of a synchronous motor and the motor field current?

  • The code box below contains a live 2D rectangular array of characters (char) called someChars. Write...

    The code box below contains a live 2D rectangular array of characters (char) called someChars. Write a looping statement that allows you to calculate, and then print to the console, the number of entries in the array that are (lower case) 'x'. For example, if the array looks like this: x o o x y y y x p q The answer you enter should execute exactly one System.out.println statement. In Java please.

  • C++ Write a program that checks whether the first digit of the entered number equals the...

    C++ Write a program that checks whether the first digit of the entered number equals the last digit.

  • An array contains the following characters in the sequence below: V Z D H A Write...

    An array contains the following characters in the sequence below: V Z D H A Write down the characters for each round according to the specified sorting algorithms which sorts the character array into its ascending order. First round always begins at the first location of the array. Bubble Sort Round 1: Round 2: Round 3: Round 4: Round 5: Selection Sort Round 1: Round 2: Round 3: Round 4: Round 5: Insertion Sort Round 1: Round 2: Round 3:...

  • Write a program that prompts the user to enter two characters and displays the major and status represented in the characters.

    Write a program that prompts the user to enter two characters and displays the major and status represented in the characters. The first character indicates the major and the second is number character 1, 2, 3, 4, which indicates whether a student is a freshman, sophomore, junior, or senior. Suppose the following characters are used to denote the majors: M: MathematicsC: Computer Science T: Testing and Certification

  • Design a Java program to reset a user's password. The password must consist of exactly six...

    Design a Java program to reset a user's password. The password must consist of exactly six characters, of which one must be a digit, one must be an uppercase letter, and one must be a lowercase letter. Tell the user if the password is correct or if incorrect tell them what is wrong with it. For example, you could say: "Not valid! the password must have 6 characters! Goodbye!" Can't contain loops. Using Boolean, String, Int, char

  • (c++) Write a predicate function that checks whether two vectors have the same elements in the...

    (c++) Write a predicate function that checks whether two vectors have the same elements in the same order. Write a predicate function that checks whether two vectors have the same elements in the same order bool equals(vector<int> a, vector<int> b) provided code : #include <iostream> #include <vector> using namespace std; bool equals(vector<int> a, vector<int> b) { // TODO } int main() { // TODO // Print Expected, "Vectors a and b are " (print "equal." if they are. Otherwise, print...

  • An array contains the following characters in the sequence below: K N M O B Write...

    An array contains the following characters in the sequence below: K N M O B Write down the characters for each round according to the specified sorting algorithms which sorts the character array into its ascending order. First round always begins at the first location of the array. • Bubble Sort Round 1:       Round 2: Round 3: Round 4: Round 5: • Selection Sort Round 1:       Round 2: Round 3: Round 4: Round 5: • Insertion...

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