Question: Execute a JavaScript when a form is submitted( The form was submited). Can verify my code cuz is not working in Chrome and IE. Also
Execute a JavaScript when a form is submitted( The form was submited). Can verify my code cuz is not working in Chrome and IE. Also the dynamic code need to verify if is correct I created in separted file too. HTML, Javacsript + dimanic
_____________________________________________-
!DOCTYPE html>
function validate_form() {
if (document.emp.username.value == "") {
alert("Please Enter your username");
return false;} else {alert ("Username Sucessfuly"); return true;} }
if (document.emp.password.value == "") {
alert("Please enter your password.");
return false;
}
if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/).test(document.emp.email_id.value)) {
alert("You have entered an invalid email address!")
return (false)
}
if (document.emp.membership.value == "Default") {
alert("Please select a membership.");
return false;
}
if (document.emp.db_y.value == "") {
alert("Please enter a year in BirthDate");
return false;
}
if (document.emp.db_m.value == "") {
alert("Please enter a month in BirthDate");
return false;
}
if (1<=document.emp.db_m.value<=12) {
alert("Please enter a month between 1 and 12 in BirthDate");
return false;
}
if (document.emp.db_d.value == "") {
alert("Please enter a date in BirthDate");
return false;
}
{
alert("sucessfully Submitted");
}
//-->
--------------
// dynValue.js
// Illustrates dynamic values var helpers = ["Your name must be in the form: \ first name, middle initial., last name", "Your email address must have the form: \ user@domain", "Your user ID must have at least six characters", "Your password must have at least six \ characters and it must include one digit", "This box provides advice on filling out\ the form on this page. Put the mouse cursor over any \ input field to get advice"] // *********************************************************** // The event handler function to change the value of the // textarea function messages(adviceNumber) { document.getElementById("adviceBox").value = helpers[adviceNumber]; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
