• Home
  • Archives
Subscribe: Posts | Comments | E-mail
  • Tech CornerNews and tips on latest gadgets.
  • Web Analytics / MarketingTips on SEO, Google Analytics, WebTrends
  • Web DevelopmentHTML, CSS, JavaScript, Ajax, jQuery, PHP, Flash.

Dr. Div

Posted on July 2, 2009 - by Dr. Div

Simple Javascript Alert for a Required Field

Web Development

Here is a simple way of checking for existence of any value in a specific form field:

Insert this code insisde the head tag on your page:
<script type="text/javascript">
function checkField(){
if (document.myForm.myField.value == ""){
alert ("Please Insert Field");
return false;
}
else{
document.myForm.submit();
}
}
</script>

Insert this code inside the body tag on your page:
<body>
<form action="http://www.drdiv.com" method="post" name="myForm" onSubmit="return checkField();">
<input name="myField" type="text" value=""/>
<input name="" type="submit" value="send"/>
</form>
</body>

0 Comments



Leave a Comment

All Symptoms Welcome

  1. Name (required)

    Mail (required)

    Website

    Message

  • Worth-a-watch Ads

  • RSS Latest Gadget News by Engadget

    • Razer and Sixense distribute SDK and FPS shooter utility through Steam
    • Motorola CLIQ XT hands-on
    • Microsoft shows off XNA games running on Windows Phone, full 3D is a go
    • Entelligence: Aiming high or another Mylo?
    • Does Android dream of DIY cushions?
  • Tag Cloud

    • Amazon Android apple Apple Tablet App Store AT&T BlackBerry Bluetooth Chrome Engadget Facebook Gadgets Gaming Google Hardware Home Theater HTC Intel iPad iPhone Kindle latest gadgets LG Mac Microsoft Mobile Motorola Nexus One Nokia Online Other PC PS3 Software Sony Sprint Steve Jobs T-Mobile Twitter Verizon wifi Windows 7 Windows Mobile Yahoo YouTube
© 2009 Dr. Div - Website Prognosis & Therapy