I have a quick question which I am a bit confused about...
I know in HTML you can have fields required in a form but I want to make the full name field below required which is fine
<input type="text" name="fullname" id="fullname" placeholder="Full
Name" required="required"/><br/>
But the tiny issue I am having which I dont know how to fix is I want to make the other field optional so the user can submit the form even without filing it out.
<input type="text" name="Other" id="fullname"
placeholder="Other"/><br/>
Any ideas ?
Thanks ! :)
Fields are optional by default. Don't put the "required" flag if you don't want it to be required...!
Just remove the required attribute from the one you want to be optional and it won't require that to be filled out for submission.
Related
I'm reviewing my code wrote time ago. The input text that I wrote is the following:
<input type="text" class="form-control form-control-sm" id="mypid" name="mypid" value="" placeholder="" readonly="readonly" required>
I tested the form and with my surprise I found out that even if I added 'required', I can actually submit even if the field is empty. The field is readonly because my code will autofill that field automatically, I need that the user doesn't write anything by themselves, so I need it to be readonly and required at the same time. But I didn't expect to see that now it's not considered required anymore. What am I doing wrong here? Any suggestion? Thank you very much for your help.
Elliot
your question has already been answered here. But to explain it to you, you have to replace your readonly by onkeypress="return false;" which gives almost the same result.
How do I prevent a form from suggesting auto-complete values, from previous entries or from saved information in Edge?
In the above image, the email input field is marked as autocomplete="false", but still in the right pane you can see the suggestion is populating.
When I add autocomplete=disabled to one field it seems it work, but when I add the attribute to all the inputs, it again starts displaying suggestions for every field.
What is the solution for this?
Add the aria-autocomplete="list" attribute to the input.
<input type="text" id="FirstName" name="attr1" aria-autocomplete="list">
Do not use any other value for the attribute.
According to your description, I reproduced the problem. I think your issue is caused by the "Save and fill personal info" setting being enabled in Edge.
If you navigate to edge://settings/personalinfo and disable this feature, you can see this behavior no longer exists.
Or you can also click the "Manage personal info" option in the picture you provided, and then disable it.
I did some simple tests and found that if you need to solve the problem from the code, you need to modify the name attribute of the form's related field.
Like this(do not use attribute values like name or email... and maybe there are others I am not aware of):
<label for="attr1">attr1:</label>
<input type="text" id="FirstName" name="attr1">
<label for="attr2">attr2 :</label>
<input type="text" id="LastName" name="attr2">
<label for="attr3">attr3 :</label>
<input type="email" id="Email" name="attr3" autocomplete="off">
<input type="submit">
I don't recommend this, because good naming helps you understand and maintain the code. Using proper attributes like name and email also helps your code be more accessible for screen readers or other assistive technology.
I need a specific pattern for email input. There should be 2 options:
john#doe.com
john#doe.com:anything
I need to fit in the ":anything" and make more possibilities after ":".
At the moment I'm using this but it does only validation for normal email:
<input class="input-fields" id="formUsername" name="username" type="text" pattern="[a-z0-9._%+-]+#[a-z0-9.-]+\.[a-z]{2,3}" autofocus required/>
I tried many combinations but I just can figure out the right one.
You could add ':?\w*' to Your regex, so it would look like
[a-z0-9._%+-]+#[a-z0-9.-]+.[a-z]{2,3}:?\w*
can't you just add more textboxes(only for the extra part fiddle here)?
Optional(only for blahblahblah):
<input class="optional-fields" title="optional" id="designation" type="text" pattern="[a-z]{5,}">
I am trying to use multiple patterns for an input-field in HTML5.
<input type="text" pattern="\d*.{5,10}" name="plz">
My current input field does not work. Only the second pattern .{5,10} is relevant for the submit. The first attribute \d* hast no effects.
Try the below:
<input type="text" placeholder="" class="form-control" pattern="([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{4})([0-9]{1})">
and just accept AESE640526HOCCNL05...
Hope this can help you.
I have never seen this, have no idea what is going on:
<form action="/cgi-bin/Lib.exe" method=POST name="slider" ID="Form2">
<input type="text" name="user" value="" ID="Text1">
<input type="text" name="end" value="" ID="Text2">
</form>
function setval()
{
alert(s.getValue());
alert(s2.getValue());
document.slider.user.value = s.getValue();//set value of hidden text box to value of slider
document.slider.end.value = s2.getValue();//set value of hidden text box to value of slider
document.slider.submit();
}
When submitting form from setval(), when I change the name of the first input box from "user" to anything else, my cgi application won't except it and I get an error? I can change the name of the secons input box to anyting and it doesn't seem to have any problem? Confused. Thanks!
Seems more like it's a problem with the cgi than it is with the HTML/Javascript, to me. It probably makes the assumption that a value for "user" will always be sent. Not much else I can tell you without seeing the form-processing code.
Your CGI must be expecting an element called 'user'. You would need to check the source.