dcsimg
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Web
Expertise: Intermediate
Feb 21, 2002

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Trim the Contents of HTML Form Elements


To use this tip, the HTML form element which is required for Null Check should assign the title property some value concatenated with "C." For example:
 
<input type=text name=txtName title="C-Name">

On the submit tag, call the following function:
 
<input type=submit onClick="return CheckNull">

<script language=javascript>

function CheckNull()
{
	i=0
	for (i=0;i<document.frm.length;i++)
		{
		strValue= new String();
		strValue=document.frm.elements[i].title;

		if(strValue.length==0) {}
		else
				{
			Trim(document.frm.elements[i]);

			if(strValue.substr(0,1)=="C" &&
document.frm.elements[i].value.length==0)
				{
				alert("Enter The value  " _
+ strValue.substr(2,strValue.length))
				document.frm.elements[i].focus()
				return false;
				break;
			 }
			}
			}
}

function Trim(text)
	{
	while(text.value.charAt(0)==' ')
	text.value=text.value.substring(1,text.value.length )
	while(text.value.charAt(text.value.length-1)==' ')
	text.value=text.value.substring(0,text.value.length-1)

	}
</script>
Narender Saraswati
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date