Home > Ask the Domino Experts > Questions & Answers > Code for validation on a field
Ask The Domino Expert: Questions & Answers
EMAIL THIS

Code for validation on a field

Dave Hatter EXPERT RESPONSE FROM: Dave Hatter

Pose a Question
Other Domino Categories
Meet all Domino Experts
Become an Expert for this site
>
QUESTION POSED ON: 07 May 2002
I would like to ask you if you have JavaScript code which does the validation on a field. If nothing is put in to the field from the user, a warning pops up and reminds the user that the field has to be filled in or something. I would appreciate it if you can help me on this.

>
The following code contains HTML and JavaScript that implements one simple way of doing this. You should be able to save the following code as an HTML file in your file system to test it. You could put the JavaScript functions in the JSHeader event of your form and add the call to ValidateForm in the form's onSubmit event.

<html>
<head>
	<title>SearchDomino Test</title>
	<SCRIPT language="JavaScript">	
			function validateForm(form){
				// Last mods 020518 - dhatter@libertastechnologies.com - www.libertastechnologies.com
				with(form){
					if(! isFieldEmpty(email)){
						return(false);
					}
			 	return(true);
				}
			}
			
			function isFieldEmpty(objField){
				// Last mods 020518 - dhatter@libertastechnologies.com - www.libertastechnologies.com
				if(objField.value==''){
					alert('Please enter a value for ' + objField.name + '.');
					objField.focus();
					return(false);
				}else{
					return(true);
				}
			}
	</SCRIPT>
</head>

<body>
<FORM action="" method="POST" onSubmit="return(validateForm(document.forms[0]))">
e-Mail Address: <INPUT name="email" value="" type="text"><BR>
<INPUT type="submit" value="Submit">
</FORM>
</body>
</html>


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Lotus Notes Domino on Blackberry and mobile devices
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts