I'm doing a form in HTML5 and I receive an error message that says:"match the requested format" and I don't know why, I attach the code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form action="" method="GET">
<input type="text" name="nombre" id="nombre" placeholder="Nombres" required pattern="[a-z]">
<br />
<input type="text" name="apellidos" id="apellidos" placeholder="Apellidos" required pattern="[a-z]">
<br />
<input type="submit" value="Enviar">
</form>
</body>
</html>
Your regular expressions only allow for one lower case character.
If you want that to be multiple characters, you'd need to add a + sign:
pattern="[a-z]+"
(Technically, since the fields are marked as required, an asterisk (*) would serve the same purpose.)
Related
I need to show a single/multiple choice question to a user with a title saying "Question" and in the next line the question.
Then, the four options should be radio buttons (for single answer and checkboxes for multiple answer).
If correct answer is selected
turn correct answer background to green
expand the solution and explanation
If wrong answer is selected,
the background of selected/wrong option should turn red
the background of right option should turn green
-expand the solution and explanation
Anyway, the user can expand the answer and explanation without answering the question.
Please provide html, code for thes functionality
Only because I'm thirsty to increase my reputation points, I made a quick solution for your "question" smh
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Simple Quiz</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- <link rel="stylesheet" href=""> -->
</head>
<body>
<h1> Q1. What is 9+10?</h1>
<input type="radio" name="question1" id="correct">21<br>
<input type="radio" name="question1" >22<br>
<input type="radio" name="question1" >19<br>
<input type="radio" name="question1" >15<br>
<input type="submit" name="submit" value="submitQuiz" onclick="result()"/>
<script type="text/javascript">
function result(){
let score=0;
if (document.getElementById('correct').checked) {
score++
document.write("🟢Correct!!! - 9+10 does equal 21 because, if you start with 9 and add 10 to that number it will equal 21")
} else {
score--
document.write("🔴Incorrect bozo! - 9+10 equals 21 because if you start with 9 and add 10 to that number it will equal 21")
}
}
</script>
</body>
I want the zip code part of my form, so only 5 numbers allowed, to reject anything that doesn't start with 46,52,53,54,60,61,62 using an html pattern
Try the below pattern (starts with one of the specified numbers and then allow 3 digits):
^(46|52|53|54|60|61|62)([0-9]{3})$
Here is the running HTML sample. You may use this pattern in Javascript as well if you want to perform the validation yourself:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Prescriptions</title>
</head>
<body>
<form action="#">
Country code: <input type="text" name="country_code" pattern="^(46|52|53|54|60|61|62)([0-9]{3})$"
title="Enter five digit number starting with specific numbers">
<input type="submit">
</form>
</body>
I'm working on a HTML page on which i got some input controls.
In these input controls the user shall enter a float number, p.e. "1234,56" with four integers before the point/comma and two integers behind (at maximum).
How can i find out while or after entering the value, if the value is correct (number of integers before and behind the point/comma; only integers).
Thanks in advance!
We can do that by placing our control on a form, using the pattern property of the input and a submit-button for comparing the pattern with the value.
First example:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Checking floatnumbers</title>
<meta charset="utf-8" />
</head>
<body>
<form>
<input type="text"
maxlength="7"
placeholder="____,__"
title="Please use format ####,##"
pattern="\d{1,4}(|\.|,)?\d{1,2}" />
<br />
<!-- For testing input patterns -->
<input type="submit"
value="Submit" />
<br /><br />
<!-- Resets/clears the form -->
<input type="reset"
value="Reset" />
</form>
</body>
</html>
First the input must be of type "text", not "number" as usual.
The pattern means, that the user can/must enter 1 to 4 numbers before the point or comma.
The point/comma and the following 1 to 2 decimals can be entered but it's not necessary.
If an user enters p.e. "12345" and clicks the submit-button it will show an error with the text from the property title.
Maybe some users don't want to enter a number like "1,23" but - because they are in a hurry - just ",23".
So we will take a look at the second example.
Second example:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Checking floatnumbers</title>
<meta charset="utf-8" />
</head>
<body>
<form>
<input type="text"
maxlength="7"
placeholder="____,__"
title="Please use format ####,##"
pattern="\d{0,4}(|\.|,)?\d{1,2}" />
<br /><br />
<!-- For testing input patterns -->
<input type="submit"
value="Submit" />
<br /><br />
<!-- Resets/clears the form -->
<input type="reset"
value="Reset" />
</form>
</body>
</html>
As You can see the input before the point/comma has a minimum of 0 and a maximum of 4.
So it's possible to enter a floatnumber like ",23".
And if we want to enter negativ floatnumbers in the input we change the pattern to "^[+-]?\d{0,4}(|\.|,)?\d{1,2}" and the maxlength to 8.
Further notice
With the pattern above we can still enter a number like "12345" which is not correct in our case.
The correct pattern has to be: "^[+-]?\d{1,4}((\.|,)\d{1,2})?" or "^[+-]?\d{0,4}((\.|,)\d{1,2})?"
I am trying to set html form input's default language to Georgian.
i.e. when user starts typing input it should be in Georgian and user should not have to switch language from keyboard.
I tried using lang="ka" attribute on almost every element but it is not working. ("ka" is html language code reference for Georgian, and I do have Georgian keyboard installed).
<!DOCTYPE html>
<html lang="ka">
<head>
<title></title>
<meta charset="UTF-8">
</head>
<body lang="ka">
<form lang="ka">
სახელი:<br>
<input lang="ka" type="text" name="firstname" >
<br>
გვარი:<br>
<input lang="ka" type="text" name="lastname" >
</form>
</body>
</html>
I'm generating HTML reports using knitr, and I'd like to include author and generation date meta tags.
My Rhtml page looks something like this.
<html>
<head>
<meta name="author" content="<!--rinline Sys.getenv('USERNAME') -->">
<meta name="date" content="<!--rinline as.character(Sys.time()) -->">
</head>
<body>
</body>
</html>
Unfortunately, after I knit("test.Rhtml"), the HTML that knitr generates is
<meta name="author" content="<code class="knitr inline">RCotton</code>">
<meta name="date" content="<code class="knitr inline">2013-01-02 14:38:16</code>">
which isn't valid HTML. What I'd really like to generate is something like
<meta name="author" content="RCotton">
<meta name="date" content="2013-01-02 14:38:16">
Can I generate R code that doesn't get a code tag wrapping it? Or is there another way to specify tag attributes (like these content attributes)?
So far my least-worst plan is to manually fix the content with readLines/str_replace/writeLines, but this seems rather kludgy.
Another (undocumented) approach is to add I() around your inline code to print the characters as is without the <code> tag, e.g.
<html>
<head>
<meta name="author" content="<!--rinline I(Sys.getenv('USERNAME')) -->">
<meta name="date" content="<!--rinline I(as.character(Sys.time())) -->">
</head>
<body>
</body>
</html>
Not really nice, but seems to work without adding a hook:
<head>
<!--begin.rcode results='asis', echo=FALSE
cat('
<meta name="author" content="', Sys.getenv('USERNAME'), '">
<meta name="date" content="', as.character(Sys.time()),'-->">
',sep="")
end.rcode-->
</head>