HTML Pattern Input to Allow Only Specific Numbers - html

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>

Related

How to create html form that directly goes to specific search on a website?

I know that the code below will go to the result page of google when the user types some texts and the submit button is clicked.
<!DOCTYPE html>
<html lang="en">
<head>
<title>
Hello!
</title>
</head>
<body>
<form action="https://www.google.com/search" method="get">
<input name="q" type="text">
<input type="submit" value="Submit Form">
</form>
</body>
</html>
But I try this with https://www.jitta.com/. It does not seem to have the same structure as google.
When searching on this website the url will be https://www.jitta.com/stock/bkk:ptt where "ptt" is the word that I want to search. Unlike google, if I want to search "ptt" the url will be https://www.google.com/search?q=ptt.
Can it be only HTML code? no other parts involved (like Javascript,...)
Appreciate anyone who answers this.

404 not found on method POST on form

I got this simple form on a page. I run this on localhost but when I run the form it shall redirect to http://localhost:63342/welcome.html
but instead I get the 404 not found message.
When I mark the url in the browser and hit return the correct page shows. But the redirect doesnt work when using method="POST" to localhost
Any idea how to solve this?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<form method="POST" action="welcome.html">
<input type="text" id="test" name="test"/>
<input type="submit" value="test"/>
</form>
</body>
</html>
I think you want to use the GET method instead of the POST method.
Have a look here for more information: http://www.w3schools.com/TAGS/ref_httpmethods.asp

Bootstrap. What's controlling where the form is sent?

I am using Bootstrap with forms. How the "method=" or "action="?
What is telling it what to do/where to go? Should there be a "method"?
What's controlling where the form is sent?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>my form</title>
<meta name="description" content="title page.">
<link href="twitter-bootstrap-v2/docs/assets/css/bootstrap.css" rel="stylesheet">
</head>
<body>
<form class="well">
<label>test page</label>
<input type="text" class="span3" placeholder="Type something…">
<label class="checkbox">
input type="checkbox"> Remember me
</label>
<button type="submit" class="btn">Submit</button>
</form>
</body>
</html>
Your question has nothing to do with bootstrap. Those are form tag attributes.
Refer : Form_Tag
action Specifies where to send the form-data when a form is submitted
method Specifies the HTTP method to use when sending form-data. Default method is GET.
Example : <form action="next_page.html" method="get">
Notes on GET:
Appends form-data into the URL in name/value pairs
The length of a URL is limited (about 3000 characters)
Never use GET to send sensitive data! (will be visible in the URL)
Useful for form submissions where a user want to bookmark the result
GET is better for non-secure data, like query strings in Google
Notes on POST:
Appends form-data inside the body of the HTTP request (data is not shown is in URL)
Has no size limitations
Form submissions with POST cannot be bookmarked

html form input default language - not working

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>

How to force to display a number with a comma with input type number?

I have this input type number:
<input type="number">
Of course the value is a number, how to force it to display a number with a comma? And make it compatible with most HTML 5 browsers?
I searched but I didn't find a solution. I outputted a number but it is not showing with a comma.
You can use the french locale lang="fr" that use a comma for the decimal separator.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Input test</title>
<script>
function init(){
document.getElementById('in1').value = 3.14;
}
</script>
</head>
<body onload="init()">
<input id="in1" lang="fr" type="number">
</body>
</html>
It works well with Firefox 39.0:
but unfortunately it's not yet implemented in Chrome 44.