an someone please fix the error, the error is that my else statement isn't working in this scenario. (html>
Can someone please fix the error, the error is that my else statement isn't working in this scenario.
<!DOCTYPE html>
(html>
<head>
<script>
/ function to validate ucid
function validateUCID() {
text = document . getElementById("ucid") .value;
(/ regular expression to match ucid letters
// followed by 3 digit number
result = text.match(/(^ [a-zA-Z]+\d{3})+$/8);
if (result) {
alert ("VALID UCID FORMAT BUT INVALID UCID");
}
else if (result == result) {
alert("VALID UCID FORMAT AND UCID FOUND");
}
else {
alert ("UCID DOES NOT CONFORM TO VALID FORMAT");
}
// clear the text field
document . getElementById("ucid") . value = "";
}
</script>
</head>
<body>
<!--UCID TEXT FIELD-->
<input type="text" title="(e.g. abcd123" id="ucid" name="ucid" placeholder="Enter valid ucid">
<!--SUBMIT BUTTON-->
<br>
<input type="submit" value="Submit" onclick= "validateUCID()">
</body>
/html>
Trending now
This is a popular solution!
Step by step
Solved in 2 steps