Friday, April 13, 2018

Check Input in JavaScript

Here is a sample script written in JavaScript to check if the form input is valid or not and not empty.

I am currently accepting programming work, it project, school programming projects , thesis and capstone projects, IT consulting work and web development work kindly contact me in the following email address for further details. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.


Program Listing

check.htm


<html> 
<head> 
<title>Check Empty Input</title> 
<script language="JavaScript"> 
function checkEmpty(myForm) 
if (myForm.phone.value == "")      
alert("Please enter phone number!");
myForm.email.focus();
return (false); 
if (myForm.email.value == "") 
alert("Please enter email address!"); 
myForm.message.focus(); 
return (false); 
if (myForm.message.value == "") 
alert("Please leave a message!"); 
myForm.phone.focus(); 
return (false); 
}
</script>
</head> 
<body> 
<br>
<center>
  <p><strong>Check Empty Input</strong></p>
  <br>
</center> 
<form name="myForm" method="post" onSubmit="javascript:return checkEmpty(this);"> 
<table width="36" border="0" cellspacing="1" cellpadding="1" align="center"> 
<tr> 
<td>Phone:
  <input type=text name=phone size=30> 
</td> 
</tr> 
<tr> 
<td>Email:
  <input type="text" name=email size="30"> 
</td> 
</tr> 
<tr> 
<td>Message:<br>
  <textarea name=message  cols=37 rows=6></textarea> 
</td> 
</tr> 
<tr> 
<td>
<div align="right">
  <input type="submit" name="pub" value="Check Empty">
</div>
</td> 
</tr> 
</table> 
</form> 
</body> 
</html>


No comments:

Post a Comment