0

Help regarding forms in html

I want the form action to be done only when given input is what i want.. for ex (see the below code) i want the form action to be done only if i give some specific characters and click submit..in this code if i give any character and click submit, the form action is executed but i don't want that..how can i set some prefixed password using html? i want to know how can it be done using ONLY HTML not using other languages https://code.sololearn.com/WrauOVPc3OxH/?ref=app

21st Apr 2018, 8:22 AM
Ravindra Desai
Ravindra Desai - avatar
11 Réponses
+ 2
Those are event handlers. onclick, ondrag, onload etc.
21st Apr 2018, 9:17 AM
Akib
Akib - avatar
+ 1
html is markup language. so if you want to control the flow of submit, you need to apply some scripts by adding <script> tag or using event listener. ----try this code below---- this is an example using onclick event listener with not submit type input but button. (submit condition: type 'abc' on password input) <!DOCTYPE html> <html> <form action="https:/www.sololearn.com"> <input type="checkbox"value="password" name="password" >sololearn</input><br /> password: <input type="password" /> <input type="button" value="submit" onclick="if(document.querySelector('[type=\'password\']').value == 'abc') submit();"/> </form> </html>
21st Apr 2018, 8:42 AM
Code Koo
Code Koo - avatar
+ 1
in your code, what are the statements included after the value attribute? are those some sort of functions? and i have html5 yet to learn on sololearn... will those functions be included in those lessons?
21st Apr 2018, 9:15 AM
Ravindra Desai
Ravindra Desai - avatar
+ 1
oh it's alright.. thanks for sharing your knowledge
21st Apr 2018, 10:09 AM
Ravindra Desai
Ravindra Desai - avatar
+ 1
Ravindra Desai no HTML5 tutorial doesn't teach about event handlers, not in sololearn Html course. Its in the javascript course. You can also check https://www.w3schools.com
21st Apr 2018, 11:54 AM
Akib
Akib - avatar
0
You need javascript for that. There is form validation course in the learning section of js.
21st Apr 2018, 9:03 AM
Akib
Akib - avatar
0
so they will be included in html5 lessons on sololearn.. isn't it???
21st Apr 2018, 9:18 AM
Ravindra Desai
Ravindra Desai - avatar
0
the value of input type 'button' means object's display name.
21st Apr 2018, 9:43 AM
Code Koo
Code Koo - avatar
0
DOES HTML5 COURSE IN SOLOLEARN INCLUDE ONCLICK,ONDRAG AND OTHER EVENT HANDLERS?
21st Apr 2018, 10:04 AM
Ravindra Desai
Ravindra Desai - avatar
0
i don't know well the sololearn course includes those handlers. i learned the html on other courses.
21st Apr 2018, 10:07 AM
Code Koo
Code Koo - avatar
0
oh ok.. thanks..but those event handlers can be used in html right?
21st Apr 2018, 12:03 PM
Ravindra Desai
Ravindra Desai - avatar