• 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

    • Best Buy to slash prices for old Xbox 360 special edition bundles tomorrow?
    • Hacker intercepts phone calls with homebuilt $1,500 IMSI catcher, claims GSM is beyond repair
    • Switched On: The Galaxy S paradox
    • Dell Studio XPS 9100 arrives with six cores, little fanfare
    • Engadget Podcast 207 - 07.31.2010
  • Tag Cloud

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