If a text field is configured to View As HTML and the example code from...
https://www.w3schools.com/js/js_validation_api.asp
...is entered in to the text field the JS functionality seems to be disabled when the project is rendered.
See https://www.customdataservices.net/restapisdb/base_list.php for example
The code as entered in the View As HTML text field...
<p>Enter a number and click OK:</p>
<input id="id1" type="number" min="100" max="300" required>
<button onclick="myFunction()">OK</button>
<p>If the number is less than 100 or greater than 300, an error message will be displayed.</p>
<p id="demo"></p>
<script>
function myFunction() {
var inpObj = document.getElementById("id1");
if (!inpObj.checkValidity()) {
document.getElementById("demo").innerHTML = inpObj.validationMessage;
} else {
document.getElementById("demo").innerHTML = "Input OK";
}
}
</script>
I know it's an odd ball question but I'd like to be able to use some pre-existing JS-based forms in an upcoming project and need to figure this out.
Thanks, as always, for any guidance you can provide.
https://www.w3schools.com/js/js_validation_api.asp
...is entered in to the text field the JS functionality seems to be disabled when the project is rendered.
See https://www.customdataservices.net/restapisdb/base_list.php for example
The code as entered in the View As HTML text field...
<p>Enter a number and click OK:</p>
<input id="id1" type="number" min="100" max="300" required>
<button onclick="myFunction()">OK</button>
<p>If the number is less than 100 or greater than 300, an error message will be displayed.</p>
<p id="demo"></p>
<script>
function myFunction() {
var inpObj = document.getElementById("id1");
if (!inpObj.checkValidity()) {
document.getElementById("demo").innerHTML = inpObj.validationMessage;
} else {
document.getElementById("demo").innerHTML = "Input OK";
}
}
</script>
I know it's an odd ball question but I'd like to be able to use some pre-existing JS-based forms in an upcoming project and need to figure this out.
Thanks, as always, for any guidance you can provide.