|
|
|
|
|
|
| |
In this short code we are going to process a user form. and going to show an error message and change the color of a field name by using javascript.
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Form Processing : with alert Highlight field name which is not filled by user</title>
<script language="javascript" type="text/javascript">
function CheckTheForm() {
var result = true;
var msg="";
if (document.frmTest.name.value=="") {
msg+="Please enter Name! \n";
document.frmTest.name.focus();
document.getElementById('title').style.color="red";
result = false;
}
if (document.frmTest.eml.value=="") {
msg+="Email is Required!\n";
document.frmTest.eml.focus();
document.getElementById('eml').style.color="red";
result = false;
}
if(msg==""){
return result;
}{
alert(msg)
return result;
}
}
</script>
</head>
<body>
<form name="frmTest" method="post" action="test_form.html">
<table width="21%" border="0">
<tr>
<td id="title">Name</td>
<td><input type="text" name="name" /></td>
</tr>
<tr>
<td id="eml">email</td>
<td><input type="text" name="eml" /></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Submit" onclick="return CheckTheForm();" /></td>
<td><input type="reset" name="Reset" value="Reset" /></td>
</tr>
</table>
</form>
</body>
</html> | | |
|
| Adding a Filter to a Text Element Categories : Java Script, Data Validation, Form Processing | | | Db_lib - practical example usage of database abstraction and form validation.
Categories : PHP, Form Processing, PHP Classes, Data Validation, Beginner Guides | | | Validating a URL with JavaScript RegExp Categories : Java Script, Data Validation, Beginner Guides | | | Show hide table rows to make dynamic forms Categories : Beginner Guides, Java Script, Form Processing, HTTP | | | Form Validation Using PHP to highlight non valid fields Categories : PHP, Form Processing, Data Validation, Beginner Guides | | | Conditional Check - a script that allows a user to submit a form only if the user check a checkbox. Categories : HTML, Java Script, Form Processing, Beginner Guides | | | PHP and javascript mouseover, mouseout, and mousedown events Categories : PHP, Java Script, Form Processing, Beginner Guides | | | Changing the Style of form objects using the JavaScript OnClick method. Categories : Java Script, Form Processing, Beginner Guides, CSS | | | JavaScript dropdown list menu to switch any page. Categories : Java Script, Beginner Guides, Form Processing | | | Javascript URL and Email Validation Categories : Java Script, Data Validation, Form Processing, Email, URLs | | | Simple Javascript CSS Digital Clock Categories : Java Script, Date Time, CSS, Beginner Guides, Web Design | | | Easy alert box pop-up function Categories : PHP, Java Script, Beginner Guides | | | Ajax - Perform a simple server side request and update the current HTML page. Categories : AJAX, Java Script, Beginner Guides | | | CSS Vertical Navigator , With Coll CSS Look Categories : CSS, Web Design, Beginner Guides | | | A function to clean input coming from form fields (Minimize the risk for XSS and SQL Injection attacks). Categories : Beginner Guides, Security, Data Validation | |
|
|
|