I am currently doing a school project and once again, I have another question to ask! I would like to create a function that prevents my submit button from working unless the value in my "Topic" and "Question" is filled.
What I want to try doing, is to make my Submit button become display: none;
if my "topic" and "Question" field is empty.
I have tried using a if (data != 0)
or a .strLength
extension. However, I am not really sure of how it should work.
Any help will be appreciated
<!doctype html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="TestingTrueQuestionStylesheet.css">
<script>
function submitAnswer(){
var data = document.getElementById("Question").value;
var topicName = document.getElementById("TopicName").value;
localStorage.newdata = data;
localStorage.topicName = topicName;
}
</script>
</head>
<body>
<form>
<fieldset>
<input placeholder="Topic" id="TopicName" required type="text"></input>
<br/>
<textarea placeholder="Question" id="Question" required rows="30" cols="100"></textarea>
<br/>
<input type="submit" onclick="submitAnswer()" id="SubmitButton" required ></input>
</fieldset>
</form>
</body>
</html>