Jump to content
Killersites Forums

Load webpage in JS


Recommended Posts

I have created the following html page in Dreamweaver. When the user enter an age >39 the webpage must load else the alert message must be displayed. What am I doing wrong?

<!DOCTYPE html>

<h2>HTML Forms</h2>

<form action="" onSubmit="myFunction()">
    <label for="fname">First name:</label><br>
    <input type="text" id="fname" name="fname" value=""><br>
    <label for="lname">Last name:</label><br>
    <input type="text" id="lname" name="lname" value=""><br><br>
    <input type="submit" value="Submit">
<script type="text/javascript">
   function myFunction(){
     var fname = document.getElementById("fname").value;
     if(fname > 39) {
    }    else
        alert("Condition Not met")

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...