0
What method can be used to acquire the content of form?
A common action on the form is validation to ensure the content the user is entering is in an accepted format. Such as getEelmentById etc. I am new to this kind of language, I wish to get a detailed answer, thanks!
5 ответов
0
Jiang Tenghe
I think you can do it even without JavaScript
HTML5 has some form validation features built-in.
If you are validaing an email input, you can set the attribute type to email(type="email") and it only accepts data when it is in an acceptable format, for ex. user@example.com
You can do the same with JavaScript.
Go through this page,
https://developer.mozilla.org/en-US/docs/Learn/Forms/Form_validation
+ 1
use html inbuilt validation tool
like
type=number/email/date/time/color...
max= "5"
min="2"
minlength =" "
maxlength =" "
pattern =" "
most famous required boolean to make input compulsory
0
OK,I got it. Thanks!
0
if you know regex you can add it in pattern attribute of input tag
- 1
Use if else statement of Javascript.
Dom maniculation can help you to get the value of the inputs