Last active
September 17, 2024 19:10
-
-
Save miwebguy/36a67cfa1cc31920e22cf244488535bd to your computer and use it in GitHub Desktop.
Datalist Check final value against list optoins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script> | |
function peopleCheck(el) | |
{ | |
var options = el.list.options; | |
for (var i = 0; i< options.length; i++) { | |
if (el.value == options[i].value) | |
//option matches: work is done | |
return; | |
} | |
//no match was found: reset the value | |
el.value = ""; | |
var elid = el.getAttribute('id'); | |
el.reportValidity(); | |
return false; | |
} | |
<script> | |
</head> | |
<body> | |
<label for='User'>This User</label> | |
<input type='text' list='people' id='User' name="user" | |
title='Valid UserName required' | |
required='true' | |
autocomplete='off' | |
onblur="peopleCheck(this); "/> | |
<datalist id='people'> | |
<option value='duser'>Diagnostic User</option> | |
</datalist> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment