<?xml version="1.0" encoding="iso-8859-1"?><rss version="1.0"><channel><title>Diary of Shashidhar Kumar</title><link>http://shashionline.rediffiland.com/</link><description>Diary of Shashidhar Kumar</description><language>en-us</language><item><title>My First Love...</title><description><![CDATA[<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0><TBODY><TR><TD><DIV align=left> </DIV></TD></TR><TR><TD><DIV align=left><TABLE cellSpacing=0 cellPadding=0 width="100%" border=0><TBODY><TR><TD vAlign=top width=20> </TD><TD vAlign=top><FONT face=Arial color=#800000 size=3>I LOVE YOU even I don't know your name<BR>It has been more than three months or more but still<BR>I don't know your name<BR>Your beauty and the deep love that I have<BR>Make me to be afraid of you, , , to speak to you<BR>even ask you your name..... <BR></FONT></TD></TR></TBODY></TABLE></DIV></TD></TR></TBODY></TABLE>]]></description><pubDate>Wed, 29 Aug 2007 16:33:34 +0530</pubDate><link>http://tutorialforprogrammer.rediffiland.com/blogs/2007/08/29/My-First.html</link></item><item><title>Onsubmit of Forms - HTML</title><description><![CDATA[<H3 id=onsubmit>onsubmit</H3><P>When using JavaScript to check a form, the first thing you need is the <CODE><FONT color=#666666 size=2>onsubmit</FONT></CODE> event handler.<BR>This event handler specifies a script that is executed when the user submits the form. That script is where<BR>you check whether certain fields have a value, whether the user has checked at least one checkbox,<BR>and any other checks you deem necessary.</P><P>The general syntax is:</P><PRE>&lt;form action="something.pl" onsubmit="return checkscript()"&gt;<BR></PRE><PRE>where <CODE><FONT color=#666666 size=2>checkscript()</FONT></CODE> is the name of the script. This script should return either <FONT size=2><FONT color=#666666><CODE>true</CODE><BR></FONT></FONT>or <CODE><FONT color=#666666 size=2>false</FONT></CODE>. If <CODE><FONT color=#666666 size=2>false</FONT></CODE> is returned, the form will not be submitted. If either <FONT size=2><FONT color=#666666><CODE>true</CODE><BR></FONT></FONT>or <CODE><FONT color=#666666 size=2>false</FONT></CODE> is returned the script stops.</PRE><P>So the general script becomes something like:</P><PRE>function checkscript() {<BR> if (some value is/is not something) {<BR>  // something is wrong<BR>  alert('alert user of problem');<BR>  <B>return false</B>;<BR> }<BR> else if (another value is/is not something) {<BR>  // something else is wrong<BR>  alert('alert user of problem');<BR>  <B>return false</B>;<BR> }<BR><BR> // If the script makes it to here, everything is OK,<BR> // so you can submit the form<BR><BR> <B>return true</B>;<BR>}<BR></PRE><PRE>Of course this function can become much more complex if you have to check a complicated<BR>form with a lot of radio buttons and things. The general idea remains the same, however: You<BR>go through the elements, check whatever you want to check and as soon as you find any mistake, you <CODE><FONT color=#666666 size=2>return false</FONT></CODE>, after<BR>which the script stops and the form is not submitted.</PRE><P>Once you've found a mistake, you should notify the user of the problem. This used to be done by an <CODE><FONT color=#666666 size=2>alert</FONT></CODE>,<BR>but nowadays you can <A href="http://tutorialforprogrammer.blogspot.com/dom/error.html"><FONT color=#473624>generate error messages</FONT></A> and insert them next to the form field.</P><P>Only at the very end of the script, when you have checked all elements and encountered no mistakes,<BR>you <CODE><FONT color=#666666 size=2>return true</FONT></CODE>, after which the form is submitted.</P>]]></description><pubDate>Thu, 23 Aug 2007 15:33:41 +0530</pubDate><link>http://tutorialforprogrammer.rediffiland.com/blogs/2007/08/23/Onsubmit-of-Forms-.html</link></item><item><title>Accessing the form elements - HTMl</title><description><![CDATA[<H3 id=access>Accessing the form elements</H3><P>The form validation script needs to access the form in the HTML page to determine<BR>what values the user has filled in. So first we have to enter the form by means of the<BR><A href="http://tutorialforprogrammer.blogspot.com/2007/08/dom0.html"><FONT color=#473624>Level 0 DOM</FONT></A>.<BR>The general syntax for accessing a form element is:</P><PRE>document.forms[number].elements[number]</PRE><PRE><BR>When the page is loaded, JavaScript makes an array <CODE><FONT color=#666666 size=2>forms</FONT></CODE> in which it<BR>puts all the forms that are on the page. The first form is <CODE><FONT color=#666666 size=2>forms[0]</FONT></CODE>, the<BR>second is <CODE><FONT color=#666666 size=2>forms[1]</FONT></CODE> etc.</PRE><P>Each form has another array in which JavaScript puts all the elements in the form.<BR>The first elements is <CODE><FONT color=#666666 size=2>elements[0]</FONT></CODE>, the second <CODE><FONT color=#666666 size=2>elements[1]</FONT></CODE> etc.<BR>Every <CODE><FONT color=#666666 size=2>&lt;input&gt;, &lt;select&gt; and &lt;textarea&gt;</FONT></CODE> is an element.</P><P>In some cases, it's better to use the names of the forms and elements. In HTML, you have<BR>to give a <CODE><FONT color=#666666 size=2>name</FONT></CODE> to each form and each element, like:</P><PRE>&lt;form name="personal" action="something.pl" onsubmit="return checkscript()"&gt;<BR>&lt;input type=text size=20 name=name&gt;<BR>&lt;input type=text size=20 name=address&gt;<BR>&lt;input type=text size=20 name=city&gt;<BR>&lt;/form&gt;<BR></PRE><PRE>Now you can access these elements by:</PRE><PRE>document.personal.name<BR>document.personal.address<BR>document.personal.city<BR></PRE><PRE>The advantage of using names is that you can put all elements somewhere else in the page<BR>and still have a working script, while a script using numbers will have to be changed.<BR>After all, the input box <EM>city</EM> is <CODE><FONT color=#666666 size=2>document.forms[0].elements[2]</FONT></CODE> in<BR>the example above, but when you suddenly put it at the top of the form, it becomes<BR><CODE><FONT color=#666666 size=2>document.forms[0].elements[0]</FONT></CODE> and you have to change the script.</PRE><P>When you start writing your own scripts using the code snippets below, it is<BR>always very important to know exactly how your form is built. To help you, I<BR>wrote a <A href="http://tutorialforprogrammer.blogspot.com/2007/08/formpr.html"><FONT color=#473624>form printing script</FONT></A> that<BR>prints out the form structure for you.</P>]]></description><pubDate>Thu, 23 Aug 2007 15:33:35 +0530</pubDate><link>http://tutorialforprogrammer.rediffiland.com/blogs/2007/08/23/Accessing-the-form-elements-.html</link></item><item><title>Form methods and properties - HTML</title><description><![CDATA[<H3 id=methods>Form methods and properties</H3><P>JavaScript has a few built-in methods and properties for dealing with forms. Three of them<BR>are especially important:</P><P>You can submit a form by using the <CODE><FONT color=#666666 size=2>submit()</FONT></CODE> method. To submit the first form on<BR>the page, do</P><PRE>document.forms[0].submit()</PRE><PRE><BR>Please note that when a form is submitted by JavaScript <B>the <CODE><FONT color=#666666 size=2>onsubmit</FONT></CODE> event handler<BR>is never executed</B>.<BR><BR>To reset the form, do</PRE><PRE>document.forms[0].reset()</PRE><PRE><BR>I assume, but have not tested, that the <CODE><FONT color=#666666 size=2>onreset</FONT></CODE> event handler isn't executed<BR>either if you reset the form through JavaScript.</PRE><P>Finally, you can change the ACTION of a form if you want to:</P><PRE>document.forms[0].action = 'the_other_script.pl';<BR></PRE><PRE>This can come in very handily if a form has to be submitted to another script in some<BR>cases.</PRE>]]></description><pubDate>Thu, 23 Aug 2007 15:32:20 +0530</pubDate><link>http://tutorialforprogrammer.rediffiland.com/blogs/2007/08/23/Form-methods-and-properties-.html</link></item><item><title>Limitations of Forms - HTML</title><description><![CDATA[<H3 id=limits>Limitations</H3><P>First of all, you should have a clear idea of what happens when a user submits a<BR>form that has a JavaScript validation script:</P><OL><LI>The form is checked by a JavaScript like the one described below.<BR>If the script finds a mistake the submission is halted here. The user sees an alert<BR>and is asked to re-enter some data.<BR><LI>If nothing is wrong—or if JavaScript is disabled—the form is sent to the server and is processed by a CGI<BR>script.<BR><LI>If the CGI script finds a mistake it generates some HTML with an error message<BR>and sends it back to the user. In this case the user has to go back to the form,<BR>re-enter some values and again submit it.<BR><LI>If no mistakes are found, the CGI script does whatever it has to do with the data<BR>and directs the user to a Thank You page.<BR></LI></OL><P>As you see, the form is checked for mistakes <EM>twice</EM>: by the JavaScript<BR>and by the CGI script. The CGI check always works, since CGI is server side. The<BR>JavaScript check only works when the user has JavaScript enabled.<BR>It follows that the CGI check is the most reliable: it always works regardless of<BR>what browser is used. Then why use a JavaScript check too?</P><P>The JavaScript check is very useful <EM>in addition to</EM> the CGI check because it<BR>can catch mistakes before the form is actually sent to the server. Thus the user doesn't have to<BR>use his <EM>back</EM> button to return to the form, something that may cause confusion, and then<BR>search for the incorrect form field, which may cause even more confusion.<BR>Therefore the JavaScript check is more user friendly than the CGI check.</P><P>In addition, when you use JavaScript the<BR>server doesn't need to spend quite so much time in error handling and is thus a little<BR>quicker. This only matters if you have lots and lots of forms, but it's good to<BR>keep it in mind.</P><P>So JavaScript is <EM>not</EM> a fail-safe method of catching mistakes, but it is very<BR>useful as an addition to CGI checks since it lightens the load on the server and is<BR>more user friendly.<BR>Therefore I recommend using <EM>both</EM> JavaScript form checks <EM>and</EM> CGI form checks. This<BR>way, you get both user friendliness and security.</P>]]></description><pubDate>Thu, 23 Aug 2007 15:31:24 +0530</pubDate><link>http://tutorialforprogrammer.rediffiland.com/blogs/2007/08/23/Limitations-of-Forms-.html</link></item><item><title>Introduction to Forms - HTML</title><description><![CDATA[<H2>Introduction to Forms</H2><DIV id=header></DIV><DIV class=floater><P>However, this page contains a more complete overview<BR>of how to write a basic form validation script.</P></DIV><P class=intro>On this page I give the code you need for checking user input in a form.<BR>Using these bits of code, you can write your own scripts to validate forms</P><P>I can't give you a complete script, because each form and each check are different.<BR>You'll have to use the elements I explain on this page to build your own script.<BR>I created an <A href="http://tutorialforprogrammer.blogspot.com/2007/08/formex.html"><FONT color=#473624>example form and script</FONT></A> that you can study to<BR>get the hang of it.</P><P>On this page I discuss the<BR><A class=page href="http://tutorialforprogrammer.blogspot.com/2007/08/blog-post.html#limits"><FONT color=#956839>limitations</FONT></A> of using JavaScript to check a form, then I'll explain the<BR><A class=page href="http://tutorialforprogrammer.blogspot.com/2007/08/blog-post.html#onsubmit"><FONT color=#956839>onsubmit event handler</FONT></A>, followed by the few<BR><A class=page href="http://tutorialforprogrammer.blogspot.com/2007/08/blog-post.html#methods"><FONT color=#956839>methods and properties</FONT></A> of the form itself.<BR>Then it's time for<BR><A class=page href="http://tutorialforprogrammer.blogspot.com/2007/08/blog-post.html#access"><FONT color=#956839>accessing the form elements</FONT></A> and the specific syntax for accessing<BR>the user defined<BR><A class=page href="http://tutorialforprogrammer.blogspot.com/2007/08/blog-post.html#value"><FONT color=#956839>value</FONT></A> of form elements.</P><P class=smaller>See also Jeff Howden's excellent article<BR><A href="http://www.evolt.org/article/rating/17/28553/index.html" <FONT color=#473624>class="external" &gt;Forms &amp; JavaScript Living Together in Harmony</FONT></A><BR>for some of the most common usability errors and their solutions.</P>]]></description><pubDate>Thu, 23 Aug 2007 15:28:58 +0530</pubDate><link>http://tutorialforprogrammer.rediffiland.com/blogs/2007/08/23/Introduction-to-Forms-.html</link></item><item><title>Email Validation script - JavaScript</title><description><![CDATA[var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i<BR><BR>function checkmail(e){<BR>var returnval=emailfilter.test(e.value)<BR>if (returnval==false){<BR>alert("Please enter a valid email address.")<BR>e.select()<BR>}<BR>return returnval<BR>}<BR><BR>For more info : <A href="http://www.shashionline.in/" target=_blank><FONT color=#473624>www.shashionline.in</FONT></A> ]]></description><pubDate>Thu, 23 Aug 2007 11:51:04 +0530</pubDate><link>http://tutorialforprogrammer.rediffiland.com/blogs/2007/08/23/Email-Validation-script-.html</link></item></channel></rss>