JAVA SCRIPT
[Link]
<html>
<head>
</head>
<body>
<script>
function myFunction(a,b)
{
return a*b;
}
var x=myFunction(4,4)
alert(x);
</script>
</body>
2. FUNCTION WITHIN THE FUNCTION
<html>
<head>
</head>
<body>
<script>
function myFunction(a,b)
{
return a*b;
}
alert(myFunction(4,4));
</script>
</body>
</html>
3. INPUT TYPE = BUTTON
<!DOCTYPE html>
<html>
<body>
<input type="button" value="Click Me" />
<script>
function showMessage()
{
alert("Button was clicked!");
}
</script>
</body>
</html>
4. BUTTON TAG
<!DOCTYPE html>
<html>
<body>
<button >Click Me</button>
<script>
function showMessage()
{
alert("Button was clicked!");
}
</script>
</body>
</html>
5. DISPLAY TWO MESSAGE
<html>
<body>
<button >Click Me</button>
<button it</button>
<script>
function showMessage()
{
alert("Button was clicked!");
}
function displayDate()
{
alert( Date());
}
</script>
</body>
</html>
6. SUM ON ONCLICK
<html>
<head>
<html>
<head>
</head>
<body>
<form>
<label for="ab">First value:</label>
<input type="text" id="ab" name="ab" >
<label for="cd">Second value:</label>
<input type="text" id="cd" name="cd" >
<button Sum</button>
</form>
<script type="text/javascript">
function showSum() {
let sum = parseInt([Link]("ab").value)+
parseInt([Link]("cd").value)
alert("Sum is: " + sum);
}
</script>
</body>
</html>
7. FORM VALIDATION
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Form Validation</title>
</head>
<body>
<form validateForm()">
<input type="text" id="name" placeholder="Enter Name"><br><br>
<input type="text" id="email" placeholder="Enter Email"><br><br>
<input type="password" id="password" placeholder="Enter Password"><br><br>
<button type="submit">Submit</button>
</form>
<script>
function validateForm() {
let name = [Link]("name").value;
let email = [Link]("email").value;
let password = [Link]("password").value;
if (name === "" || email === "" || password === "") {
alert("All fields are required!");
return false;
}
return true;
}
</script>
</body>
</html>
--------------------------------------------------------------------------------------------------------------