I have a form to submit to my database and I need to setup restrictions on my form. Does anyone know how to limit certain links to be submitted on a form. For example, a user can only submit google.com links with anything following it, it just has to start with the root: google.com/(anything). Thanks! Below is some code of what I got now.
<input type="text"
required pattern="google.com/ | apple.com/ | facebook.com/"
/>
You need to use a regular expression, something like that:
(....google.de/.)|(....apple.com/.)
"." stands for any character
"*" stands for repeating it any amount of times
"|" is or, but you need to use brackets i think
Related
I am editing html codes for web accessibility but I faced one problem about Multiple form labels. I am using Wave plugin to check web accessibility.
Errors is
Multiple form labels
What It Means
A form control has more than one label associated with it.
The problem is that there is a page user can input user info, and a button to call pop up then the pop up has all same fields again to register if user did not input the field.
Instead of changing ID of the field in popup, is there any quick and easy way to remove the error?
From W3Schools:
The id attribute specifies a unique id for an HTML element (the value
must be unique within the HTML document).
So yes, you need to define a unique ID for each and every component. This is the only clean way to solve your problem, otherwise a screenreader could read the wrong label when you focus one of your input fields.
One way to fix this other than changing IDs is to wrap the input in the label.
<label>
First Name
<input />
</label>
This is semantically correct and avoids the labels needing for and associated input id attributes.
You obviously might need to refactor some stuff and it seems like more hard work than just changing some IDs but that is an option (I know you will have probably fixed this by now, this is more for reference if someone else comes to this question.)
See: https://stackoverflow.com/a/774065/2702894
I want to set up an HTML Form which will submit (via GET) a combination of user-entered and predefined values.
To explain with a basic example, see this form:
<form action=“/test.html“ method=“get”>
<input type=“text” name=“foo”>
<input type=“submit” value=“SUBMIT">
</form>
This form would give the url /test.html?foo=____, where the underline is whatever the user entered.
What I want to do is also have other values which are set by me and not the user, such as /test.html?foo=____&bar=presetvalue.
I have tried setting action=“/test.html?bar=presetvalue”, but that doesn’t work.
I could potentially do this with hidden fields, but that seems like a messy way to do it.
I have tried setting action="/test.html?bar=presetvalue", but that doesn’t work.
Submitting a GET form generates a new query string which replaces any existing query string.
I could potentially do this with hidden fields, but that seems like a messy way to do it.
This is exactly what hidden fields are designed for. They are the correct tool for the job.
I have an HTML form that sends a food dish. For example,
placeorder.com/order.php?id=STEAK
I want to add another value and send
placeorder.com/order.php?category=MEAT&id=STEAK
But, I don't want the user to have to select meat anywhere, since this has been already decided.
I tried to tinker with the form target and include it from there, but it didn't work.
Is there some "hidden text box" to write the category to so that it gets posted, or is there another way to do it?
Thanks in advance!
First, I just thought I'd mention that it's funny how the questions is phrased since you pretty much answered your own question:
Is there some "hidden text box"
Anyway, yes:
You can use type='hidden'
I assume that you are already using a GET form so I will just include the input part:
<input name='category' type='hidden' value='MEAT'>
A client of mine has come to me with an error on his website's signup form.
Please see this url for an example.
All of the fields marked with an a asterisk is required but the placeholders in some (Date of birth, Flat / House number, etc.) are acting as input and allowing the form to be submitted without and actual content being entered.
Does anyone have any idea of a solution?
You could just use "real" placeholders (+ modernizr), instead of faking it. But to solve your problem you could check the value against its defaultValue. You could also do this on the inputs instead of hard-coding the values.
if (input.value !== input.defaultValue && (otherchecks))
And for emptying the input you could use this instead of checking for a hard-coded value
onblur="if(this.value=='')this.value=this.defaultValue;" onfocus="if(this.value==this.defaultValue)this.value='';"
I'm writing a landing page to test a business idea.
For testing purpose, I want to write a Credit card number field, to see if the customer is actually ready to buy the product.
As it is only a test, I don't want this value to be submitted.
Actually for security purposes I don't even want this value to be sent in the request.
Is a separate form enough?
<form> Sensitive info</form>
<form>Info I want
<input type="submit">
</form>
Yes, only the elements from the one form will be sent (whichever one was submitted).
Alternatively, you could:
mark the input as disabled (either from the start, or onsubmit)
remove the name attribute of the input
put another input later in the form with the same name (it will override the value of the first)
Yes, that will work.