<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>16434jr&#039;s Blog</title>
	<atom:link href="http://16434jr.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://16434jr.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Sun, 20 Dec 2009 10:41:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='16434jr.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>16434jr&#039;s Blog</title>
		<link>http://16434jr.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://16434jr.wordpress.com/osd.xml" title="16434jr&#039;s Blog" />
	<atom:link rel='hub' href='http://16434jr.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Final Writeup</title>
		<link>http://16434jr.wordpress.com/2009/12/19/final-writeup-update-of-hw3/</link>
		<comments>http://16434jr.wordpress.com/2009/12/19/final-writeup-update-of-hw3/#comments</comments>
		<pubDate>Sat, 19 Dec 2009 07:50:04 +0000</pubDate>
		<dc:creator>16434jr</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://16434jr.wordpress.com/?p=39</guid>
		<description><![CDATA[Part 1: The problem that our language will solve The problem that we are addressing: Our jquery plugin is going to be addressing the difficulty of ensuring that the fields in an online form has valid inputs. When the owner of a website requires the user to input his information through a form or survey, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=16434jr.wordpress.com&amp;blog=10601342&amp;post=39&amp;subd=16434jr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Part 1: The problem that our language will solve</strong><br />
<em>The problem that we are addressing:</em><br />
Our jquery plugin is going to be addressing the difficulty of ensuring that the fields in an online form has valid inputs. When the owner of a website requires the user to input his information through a form or survey, certain fields, such as email, date, or url address require the input to be in a certain format. The problem is that there are numerous different types of fields, and each field could support flexible formats, making it tedious to hard-code field-checking for every form. In addition, appropriate error messages must be displayed, adding to the detail and complexity.</p>
<p><em>Example: Password validation</em><br />
A website that involves user accounts would probably want to specify certain requirements for passwords (i.e.  it must contain both a letter and a number, but must contain no spaces). Normally (without the validation plugin), if the password entered does not meet the requirements, there will be a lag before the server realizes that the password is invalid. However, with client-side validation, there would be no wait time; passwords could be verified without sending information to the server.<br />
<em><br />
Why the problem is hard:</em><br />
Many of the fields that are generally checked for validity have flexible formats that would be difficult to check on a case-by-case basis. Also, creating the mechanism for showing and hiding error messages by modifying the DOM is a task in itself.</p>
<p><em>Why the problem is worth solving:</em><br />
Most websites contain some sort of form that requires user input &#8211; whether it be a user account signup form or an elaborate search function &#8211; and form validation can be tedious and clunky if not for a validation plugin (in jquery). While similar plugins do exist, we will be addressing certain features that the other plugins do not include.</p>
<p><strong>Part 2: A similar problem</strong><br />
We studied a similar implementation of form validation, done in javascript (linked at http://developer.apple.com/internet/webcontent/validation.html). This validation script contains a javascript function that checks for correct input of form fields. Below is an example of the code that checks for passwords:</p>
<p>function checkPassword (strng) {<br />
var error = &#8220;&#8221;;<br />
if (strng == &#8220;&#8221;) {<br />
error = &#8220;You didn&#8217;t enter a password.\n&#8221;;<br />
}<br />
var illegalChars = /[\W_]/; // allow only letters and numbers<br />
if ((strng.length &lt; 6) || (strng.length &gt; 8)) {<br />
error = &#8220;The password is the wrong length.\n&#8221;;<br />
}<br />
else if (illegalChars.test(strng)) {<br />
error = &#8220;The password contains illegal characters.\n&#8221;;<br />
}<br />
else if (!((strng.search(/[a-z]+/) &gt; -1)<br />
&amp;&amp; (strng.search(/[A-Z]+/) &gt; -1)<br />
&amp;&amp; (strng.search(/[0-9]+/) &gt; -1))) {<br />
error = &#8220;The password must contain at least one<br />
uppercase letter, one lowercase letter,<br />
and one numeral.\n&#8221;;<br />
}</p>
<p>The above code essentially limits password creation to be a specific subset of the language of all strings. In particular, the first few lines of code checks that the password is not the empty string (i.e. a passowrd must be entered into the form), while the next two &#8216;if&#8217; blocks ensures that the password is between 6-8 characters long and does not contain any whitespaces or underscores. In the last &#8216;if&#8217; block, the code searches the input with regexes to specify the password to contain at least one lowercase letter, one uppercase letter, and one digit.</p>
<p><span style="text-decoration:underline;">The implementation</span><br />
All the code is in a file called validate.js, which can be called by an HTML &#8216;script&#8217; tag at the top for the webpage with the form in it. The main function is shown below:</p>
<p>function checkWholeForm(theForm) {<br />
var why = &#8220;&#8221;;<br />
why += checkEmail(theForm.email.value);<br />
why += checkPhone(theForm.phone.value);<br />
why += checkPassword(theForm.password.value);<br />
why += checkUsername(theForm.username.value);<br />
why += isEmpty(theForm.notempty.value);<br />
why += isDifferent(theForm.different.value);<br />
for (i=0, n=theForm.radios.length; i&lt;n; i++) {<br />
if (theForm.radios[i].checked) {<br />
var checkvalue = theForm.radios[i].value;<br />
break;<br />
}<br />
}<br />
why += checkRadio(checkvalue);<br />
why += checkDropdown(theForm.choose.selectedIndex);<br />
if (why != &#8220;&#8221;) {<br />
alert(why);<br />
return false;<br />
}<br />
return true;<br />
}</p>
<p>This function acts as a wrapper function which calls the subfunctions, each of which performs checks on a field (the example above described checkPassword(), which was one such subfunction). For instance, the username field on the webpage would be checked by the checkUsername() function, which simply checks that the username is not the empty string. Some of these subfunctions, such as checkUsername(), checkRadio(), and checkDropdown() were pretty straightforward &#8211; regular expressions were used to match the input to the appropriate specifications. For checkPhone() (code shown below), there was an additional library function call to strip parentheses, spaces, and dots from phone numbers:</p>
<p>var stripped = strng.replace(/[\(\)\.\-\ ]/g, &#8221;);<br />
//strip out acceptable non-numeric characters<br />
if (isNaN(parseInt(stripped))) {<br />
error = &#8220;The phone number contains illegal characters.&#8221;;<br />
}<br />
if (!(stripped.length == 10)) {<br />
error = &#8220;The phone number is the wrong length.<br />
Make sure you included an area code.\n&#8221;;<br />
}</p>
<p>The implementation does have its limitations. For example, the checkEmail() function does not check for email addresses that are RFC-compliant (this would require much more additional code). Furthermore, the code provides no support for AJAX requests, such that url&#8217;s could only be checked for correct formatting, but not existence. Also, this particular implementation was clunky in that each field check was hardcoded in javascript and there was no leeway for flexibility in the formatting of the fields &#8211; this resulted in code that was hard to reuse or update.</p>
<p><strong>Part 3: Features Our Library Will Support</strong><br />
Here you will do your initial language design. Perhaps your language is a new standalone language; perhaps it is a library &#8211; either way, here you need to ask these question:</p>
<p><em>The domain of our language:</em><br />
With our jQuery validation plugin, we wish to allow html programmers validate input forms without too much of a hassle. In particular, we want these programmers to be able to specify validation rules easily without having to specify the inner details of the checking function, or worse yet, hardcode checks against each input field.</p>
<p>To be more specific, we want users to have access to these functionalities:<br />
-do a simple form.validate() call to validate the target form with defaults rules<br />
-specify default text for input fields<br />
-specify own rules (i.e. regexp&#8217;s to match against)<br />
-specify own checking functions<br />
-specify own error messages</p>
<p>Validation will happen:<br />
-every time the submit button is clicked<br />
-after the first click of the submit button, validation will happen on all &#8216;keyup&#8217; and &#8216;focusout&#8217; (aka blur) events</p>
<p><em>Our programming model:</em><br />
Our jQuery library will adhere the jQuering programming model, or an object-oriented approach. More specifically, in our library we will be extending the jQuery object with a wrapper method called validate(options). This method will encapsulate all the details needed to handle field checking, as well as optional arguments to allow for customization. Thus, the user only has to call validate() with from the &#8220;form&#8221; element in the html page to perform validation. A few additional details:<br />
-Validation is invoked inside a &#8216;&lt;script&gt;&#8217; block inside the html file, and validate() is called after the document is ready. For example we want to write (in pseudocode):<br />
&lt;script&gt; (document).ready(function () {(form).validate(~myoptions~)}) &lt;/script&gt;<br />
-Default text is set on an element-by-element basis. That means each input field needing default text should call the DefaultValue(~default message~)<br />
-In order to specify which elements of a form need to be validated (and against which validation type), the user must modify the &#8220;class&#8221; attribute of his element tags. For example, say the user has a input field named &#8220;firstname&#8221; which he wants to make a required field. To do this, the user will set &#8216;firstname.class = &#8220;required&#8221;&#8216;. In another example, if the user wants to set an input field named &#8220;myemail&#8221; to be both required and in proper email format, he will write &#8216;myemail.class = &#8220;required email&#8221;&#8216;</p>
<p>Calling validate() without any arguments invokes the default validation rules that we have included in our plugin (i.e. required, email, and url), but users obviously might want to specify their own validation rules, such as for dates, credit card numbers, etc. To do this, the user passes in an (optional) argument to validate(); This argument will be in the form of a dictionary that maps field types to corresponding regexps. For example, say you want to validate the input type &#8220;idnum&#8221; to a five-digit number, then you would include<br />
idnum : /\d\d\d\d\d/<br />
in the argument dictionary. If a single regex is not powerful enough to check a given input type, then the user can specify his own checking functions in the same way,<br />
idnum : function () {}</p>
<p><em>Our 3 Demos:</em><br />
<span style="text-decoration:underline;">Main Demo: Form Validation</span><br />
Our main demo demonstrates all of our plugin&#8217;s features except the customizability of validation rules and error messages. In our html header section, we write:<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
$(document).ready(function() {<br />
$(&#8220;#fname&#8221;).DefaultValue(&#8220;Enter your first name&#8230;&#8221;);<br />
$(&#8220;#lname&#8221;).DefaultValue(&#8220;Enter your last name&#8230;&#8221;);<br />
$(&#8220;#pass&#8221;).DefaultValue(&#8220;MyPassword&#8221;);<br />
&#8230;.<br />
$(&#8220;#customerForm&#8221;).validate();<br />
});<br />
&lt;/script&gt;</p>
<p>As explained earlier, our plugins are called on &#8220;document.ready&#8221;. In the document.ready block, the first few lines set the default text for particular fields, while the last line makes the call to validate() to initiate validation. In addition, elements in the form have their class attribute modified to reflect what the element needs to be validated against:<br />
&lt;input type=&#8221;text&#8221; size=&#8221;30&#8243; name=&#8221;email&#8221; id=&#8221;email&#8221; accept=&#8221;" alt=&#8221;"/&gt;<br />
This specifies that the input field is required and must be of type &#8216;email&#8217;</p>
<p><span style="text-decoration:underline;">Second Demo: Custom Validation Rules</span><br />
This demo demonstrates our support for customizability of validation rules, checking functions, error messages. In this example, the html form has two field types, &#8220;num&#8221; and &#8220;numrange&#8221;. Since our default validation methods do not include checking against either of these types, the user must specify his own rules to check for num and numrange. Once again, all the plugin calls are made inside the document.ready block:<br />
$(document).ready(function() {<br />
$(&#8220;#customerForm&#8221;).validate({<br />
mymethods: {<br />
num: &#8220;^42$&#8221;,<br />
},<br />
mymethodfuncs: {<br />
numrange: function (value, element) {<br />
return this.optional(element) || ((value &gt; 23) &amp;&amp; (value &lt; 54));<br />
}<br />
},<br />
myerrors: {<br />
num: &#8220;Wrong! Guess again.&#8221;,<br />
numrange: &#8220;Do you know how to read?!?!&#8221;,<br />
}<br />
});<br />
});</p>
<p>In this code, validate() is called with an argument dictionary. There are three fields in this argument:<br />
mymethods, which contains validation rules that can be matched with just regexp&#8217;s,<br />
mymethodfuncs, which contains validation rules that need more than just a regexp to match, and<br />
myerrors, which contains custom error messages for the specified types. These rules/messages allow the user to write something like<br />
&lt;input type=&#8221;text&#8221; size=&#8221;20&#8243; name=&#8221;fname2&#8243; id=&#8221;fname2&#8243; value=&#8221;" /&gt;<br />
to validate a &#8220;numrange&#8221;.</p>
<p><span style="text-decoration:underline;">Third Demo: Hidden Form Validation</span><br />
This example shows how a single input string can be split into multiple sections, each of which can be validated separately. To do this, we call a javascript library to split the input string, and pass the resulting substrings into hidden input fields, which are not displayed to the client. A snippet of our code:<br />
$(&#8220;#codeForm&#8221;).validate({<br />
mymethods: {<br />
pname: &#8220;^[a-zA-Z][a-zA-Z]+$&#8221;,<br />
location: &#8220;^[a-zA-Z][a-zA-Z]+$&#8221;,<br />
action: &#8220;[NSEW]|([NS][EW])&#8221;<br />
},<br />
myerrors: {<br />
pname: &#8220;Please enter a valid name.&#8221;,<br />
location: &#8220;Please enter a valid location.&#8221;,<br />
action: &#8220;Please enter one of the cardinal directions.&#8221;<br />
}<br />
});<br />
&#8230;<br />
&lt;input type=&#8221;submit&#8221; value=&#8221;Validate&#8221; onclick=&#8221;decode(code.value);&#8221; /&gt;<br />
&lt;input type=&#8221;hidden&#8221; name=&#8221;pname&#8221; id=&#8221;pname&#8221; value=&#8221;" /&gt;&lt;br/&gt;</p>
<p>As can be seen, custom rules are again specified, and validation is done through the click of a submit button.</p>
<p><strong>Part 4: Implementation</strong><br />
<span style="text-decoration:underline;">Our two different approaches (from hw3)</span><br />
<em>Functional Approach:</em><br />
This type of implementation would regard the form on a webpage to be one object, and we would implement different validation methods to handle every type of field. To validate a form, the user would, for each field that needs to be validated, call a method from the form object and apply that method to the field input. This means that there is no notion of the different entries of the form as different objects. This approach would probably be more difficult to debug (since there is less encapsulation of methods, as all methods reside in one object).</p>
<p><em>Object Oriented Approach:</em><br />
For this approach, each field of a form stores its validation specifications in the field&#8217;s &#8216;class&#8217; attribute in the DOM. We use a mix of jQuery&#8217;s selector methods and Javascript&#8217;s getElementByID function to access elements in the DOM. When the page is done loading we initialize object representations for the fields&#8217; specifications and store them in the jQuery plugin. This makes the implementation more clean as the user would only have to modify the attributes for the fields he is using and leave the rest to the validator object. Debugging will be handled with a Javascript debugger, as our plugin is built on jQuery, and jQuery is built on top of Javascript. The specifications are represented with regular expressions; for instance, e-mail fields are checked against the e-mail regex.</p>
<p><span style="text-decoration:underline;">Current implementation details (post-hw3)</span><br />
<em>Frontend:</em><br />
In our project, the frontend involves calling our validation plugin under the &#8216;script&#8217; tag in an html file. An html form is validated through a single call to validate(options), so users &#8216;use&#8217; our plugin by passing in different values for the &#8216;options&#8217; argument. In our implementation, a non-null argument to validate() will be in the form of a dictionary. Furthermore, we currently support three possible fields for this argument dictionary: mymethods, mymethodfuncs, and myerrors (&#8216;mymethods&#8217; and &#8216;mymethodfunc&#8217; are used to specify validation rules, while &#8216;myerrors&#8217; is used to specify error messages). Each of these fields is itself a dictionary mapping field types to their corresponding rules or error message.</p>
<p>When the &#8216;options&#8217; argument, a dictionary of dictionaries, is passed into the validate() method of the plugin, we process it when a validator object is intialized. Inside our plugin, our validator class already has dictionary containers to store the default rules and error messages. Thus, by iterating through &#8216;mymethods&#8217;, &#8216;mymethodfuncs&#8217;, and &#8216;myerrors&#8217; separately, we can add the key value pairs inside these dicts into the originally existing containers.</p>
<p>In addition, when validate() is called, our validation code iterates through every input element in the html file and checks the value of the &#8216;class&#8217; attribute. If it not an empty string, then we use its value to do a dict lookup on the appropriate validation rule handler to apply</p>
<p><em>The core language:</em><br />
Internally, validation rules are essentially functions that match the input against a regex. Thus, we designed our custom validation rule construct such that users simply had to specify &#8216;[field type] : [regex]&#8216; to implement a new rule. This meant that in our validation plugin, we had to desugar this construct by wrapping the regexp in a function.</p>
<p>The above desugaring only applies if the user specifies his validation rules through the &#8216;mymethods&#8217; field. If the user were to specify them by using &#8216;mymethodfunc&#8217;, he would be writing out the entire checking function, and thus we can store this function directly inside our rules dictionary without any desugaring.</p>
<p><em>Internal representation:</em><br />
As mentioned earlier, validation rules and error messages are both stored as dictionaries under the validator class. A call to validate() instantiates validator, which then contains all the instance variables and methods to do the bookkeeping and handling of validation. More specifically, once the validator object is instantiated, it filters all the input elements of the DOM, and then runs its check() method on each of these elements. Since all the validation rules (both defaults and user-specified) reside in a dictionary, check() can then lookup the particular rule to apply on the input field. In addition, our &#8216;keyup&#8217; and &#8216;focusout&#8217; event handlers ensure that the validator calls check() every time such an event occurs.</p>
<p><em>Interpreter/compiler:</em><br />
Since the frontend and backend are both in JavaScript, the arguments passed in to our validate() method without any preprocessing &#8211; we simply take it as it is.</p>
<p><em>Debugging:</em><br />
Since our plugin is an extension of the jQuery language, all existing debugging tools for jQuery are at the user&#8217;s disposal. However, we also realized that the user might want additional debugging features, and thus we included a debug flag, which can be set through an argument to validate(), which when turned on would trigger alert messages at different parts of our code. For example, in our input element processing code, turning on the debug flag would call alert(element.name) for every element that is being iterated over by the code.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/16434jr.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/16434jr.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/16434jr.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/16434jr.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/16434jr.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/16434jr.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/16434jr.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/16434jr.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/16434jr.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/16434jr.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/16434jr.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/16434jr.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/16434jr.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/16434jr.wordpress.com/39/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=16434jr.wordpress.com&amp;blog=10601342&amp;post=39&amp;subd=16434jr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://16434jr.wordpress.com/2009/12/19/final-writeup-update-of-hw3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/921ef2e6811a5a322019254801735b4d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">16434jr</media:title>
		</media:content>
	</item>
		<item>
		<title></title>
		<link>http://16434jr.wordpress.com/2009/12/12/30/</link>
		<comments>http://16434jr.wordpress.com/2009/12/12/30/#comments</comments>
		<pubDate>Sat, 12 Dec 2009 04:57:07 +0000</pubDate>
		<dc:creator>16434jr</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://16434jr.wordpress.com/?p=30</guid>
		<description><![CDATA[Demo programs we want to be able to run: 1.Validate a basic form, which might include login, password, email, and website URL. Jquery plugins can actually be run on WordPress, so one example would be to test out validating fields on a wordpress form: 2. Password Strength Indicator One of the features of our plugin [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=16434jr.wordpress.com&amp;blog=10601342&amp;post=30&amp;subd=16434jr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Demo programs we want to be able to run:</p>
<p>1.Validate a basic form, which might include login, password, email, and website URL. Jquery plugins can actually be run on WordPress, so one example would be to test out validating fields on a wordpress form:</p>
<p><a href="http://16434jr.files.wordpress.com/2009/12/wp-jquery25.jpg"><img class="alignnone size-medium wp-image-31" title="wp-jquery25" src="http://16434jr.files.wordpress.com/2009/12/wp-jquery25.jpg?w=300&#038;h=144" alt="" width="300" height="144" /></a></p>
<p>2. Password Strength Indicator</p>
<p>One of the features of our plugin is to show the strength of a password based on its attributes. In our implementation, password strength will be represented by a box that will vary in color depending on how strong the password is &#8211; red for week password, and green for strong password. The password field would only be validated when the indicator is green. Our strength indicator would look similar to this example.</p>
<p><a href="http://16434jr.files.wordpress.com/2009/12/4_password-strength.jpg"><img class="alignnone size-medium wp-image-35" title="4_Password-Strength" src="http://16434jr.files.wordpress.com/2009/12/4_password-strength.jpg?w=300&#038;h=257" alt="" width="300" height="257" /></a></p>
<p>3.Default values for form fields</p>
<p>Another demo that we would want to show is to provide default values for form fields. Thus, forms using our plugin will be displayed with default values in their fields (if applicable). Once the user clicks inside the field, however, the default value will be cleared.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/16434jr.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/16434jr.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/16434jr.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/16434jr.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/16434jr.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/16434jr.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/16434jr.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/16434jr.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/16434jr.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/16434jr.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/16434jr.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/16434jr.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/16434jr.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/16434jr.wordpress.com/30/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=16434jr.wordpress.com&amp;blog=10601342&amp;post=30&amp;subd=16434jr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://16434jr.wordpress.com/2009/12/12/30/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/921ef2e6811a5a322019254801735b4d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">16434jr</media:title>
		</media:content>

		<media:content url="http://16434jr.files.wordpress.com/2009/12/wp-jquery25.jpg?w=300" medium="image">
			<media:title type="html">wp-jquery25</media:title>
		</media:content>

		<media:content url="http://16434jr.files.wordpress.com/2009/12/4_password-strength.jpg?w=300" medium="image">
			<media:title type="html">4_Password-Strength</media:title>
		</media:content>
	</item>
		<item>
		<title>Part 3: What features specifically will your language support.</title>
		<link>http://16434jr.wordpress.com/2009/11/21/part-2-study-a-language-that-solves-a-similar-problem/</link>
		<comments>http://16434jr.wordpress.com/2009/11/21/part-2-study-a-language-that-solves-a-similar-problem/#comments</comments>
		<pubDate>Sat, 21 Nov 2009 07:47:06 +0000</pubDate>
		<dc:creator>16434jr</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://16434jr.wordpress.com/?p=7</guid>
		<description><![CDATA[Here you will do your initial language design. Perhaps your language is a new standalone language; perhaps it is a library &#8211; either way, here you need to ask these question: 1. The domain: What programs do you intend to write in you language? Write down the programs that you intend to write by the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=16434jr.wordpress.com&amp;blog=10601342&amp;post=7&amp;subd=16434jr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here you will do your initial language design. Perhaps your language is a new standalone language; perhaps it is a library &#8211; either way, here you need to ask these question:</p>
<p>1. The domain: What programs do you intend to write in you language? Write down the programs that you intend to write by the end of the Final Project. Is there an exciting demo among them? Remember, the narrower the domain the easier to develop the language.</p>
<p>We intend to create a form and field validation metaprogramming library that plugs into JQuery. Programs will use this library to abstract away actions like verifying URLs and sanitizing user input. The set of library functions would include:<br />
Validation by field type &#8211; types range from passwords to e-mails, URLs, among others<br />
Individual field validation &#8211; validation for select fields on the form<br />
Complete form validation &#8211; validation for all fields on the form.</p>
<p>2. Your programming model: You have been exposed to functional, OO, dependence-based programming, to declarative programming for text processing (regexes) and parsing (grammars and syntax-directed translation), and to metaprogramming (greasemonkey). Which model is suitable for your domain? Chances are it is not on the list above. It&#8217;s possible you need to invent your own.</p>
<p>We intend to use the object-oriented model; our library will be written as a JQuery plugin. Form and field objects will be initialized from the raw form data. There will be functions associated with those objects to facilitate validation and data extraction.</p>
<p>3. Write an example program in your language: Pick the simplest from the list in point one and write it in your language. The semantics need not be fully fleshed out yet, as long as you understand which parts of the semantics are not defined yet.</p>
<p>Ignoring exact syntax, the idea would be something like this:<br />
FormObject registrationForm = [formData]<br />
registrationForm.validate()</p>
<p>This will pull a form&#8217;s data and initialize an object represntation of the form, and then the validate function will inspect each field and verify that it conforms to each field&#8217;s specs. An alternative method would be to directly validate the form data.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/16434jr.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/16434jr.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/16434jr.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/16434jr.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/16434jr.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/16434jr.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/16434jr.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/16434jr.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/16434jr.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/16434jr.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/16434jr.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/16434jr.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/16434jr.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/16434jr.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=16434jr.wordpress.com&amp;blog=10601342&amp;post=7&amp;subd=16434jr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://16434jr.wordpress.com/2009/11/21/part-2-study-a-language-that-solves-a-similar-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/921ef2e6811a5a322019254801735b4d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">16434jr</media:title>
		</media:content>
	</item>
		<item>
		<title>Part 4: Decide on the implementation.</title>
		<link>http://16434jr.wordpress.com/2009/11/20/hello-world/</link>
		<comments>http://16434jr.wordpress.com/2009/11/20/hello-world/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 23:05:06 +0000</pubDate>
		<dc:creator>16434jr</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Functional Approach This type of implementation would regard the form on a webpage to be one object, and we would implement different validation methods to handle every type of field. To validate a form, the user would, for each field that needs to be validated, call a method from the form object and apply that [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=16434jr.wordpress.com&amp;blog=10601342&amp;post=1&amp;subd=16434jr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Functional Approach</strong></p>
<p>This type of implementation would regard the form on a webpage to be one object, and we would implement different validation methods to handle every type of field. To validate a form, the user would, for each field that needs to be validated, call a method from the form object and apply that method to the field input. This means that there is no notion of the different entries of the form as different objects. This approach would probably be more difficult to debug (since there is less encapsulation of methods, as all methods reside in one object).</p>
<p><strong>Object Oriented Approach</strong></p>
<p>For this approach, we would treat each field of a form as a separate object, and implement our validation specifications by creating methods for each particular field object. This makes the implementation more clean as the user would only have to access objects that correspond to the fields he is using.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/16434jr.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/16434jr.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/16434jr.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/16434jr.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/16434jr.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/16434jr.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/16434jr.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/16434jr.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/16434jr.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/16434jr.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/16434jr.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/16434jr.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/16434jr.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/16434jr.wordpress.com/1/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=16434jr.wordpress.com&amp;blog=10601342&amp;post=1&amp;subd=16434jr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://16434jr.wordpress.com/2009/11/20/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/921ef2e6811a5a322019254801735b4d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">16434jr</media:title>
		</media:content>
	</item>
		<item>
		<title>Part 1: Choose the problem that your language will solve</title>
		<link>http://16434jr.wordpress.com/2009/11/19/part-4-decide-on-the-implementation/</link>
		<comments>http://16434jr.wordpress.com/2009/11/19/part-4-decide-on-the-implementation/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 08:31:16 +0000</pubDate>
		<dc:creator>16434jr</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://16434jr.wordpress.com/2009/11/21/part-4-decide-on-the-implementation/</guid>
		<description><![CDATA[The problem that we are addressing: Our jquery plugin is going to be addressing the difficulty of ensuring that the fields in an online form has valid inputs. When the owner of a website requires the user to input his information through a form or survey, certain fields, such as email, date, or url address [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=16434jr.wordpress.com&amp;blog=10601342&amp;post=19&amp;subd=16434jr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>The problem that we are addressing:</strong></p>
<p>Our jquery plugin is going to be addressing the difficulty of ensuring that the fields in an online form has valid inputs. When the owner of a website requires the user to input his information through a form or survey, certain fields, such as email, date, or url address require the input to be in a certain format. The problem is that there are numerous different types of fields, and each field could support flexible formats, making it tedious to hard-code field-checking for every form. In addition, appropriate error messages must be displayed, adding to the detail and complexity.</p>
<p>Example: Password validation</p>
<p><a href="http://16434jr.files.wordpress.com/2009/11/jquery_image.jpg"><img title="validation_example" src="http://16434jr.files.wordpress.com/2009/11/jquery_image.jpg?w=300&#038;h=170" alt="" width="300" height="170" /><br />
</a></p>
<p>A website that involves user accounts would probably want to specify certain requirements for passwords (i.e.  it must contain both a letter and a number, but must contain no spaces). Normally (without the validation plugin), if the password entered does not meet the requirements, there will be a lag before the server realizes that the password is invalid. However, with client-side validation, there would be no wait time; passwords could be verified without sending information to the server.</p>
<p><strong>Why the problem is hard:</strong></p>
<p>Many of the fields that are generally checked for validity have flexible formats that would be difficult to check on a case-by-case basis. Also, creating the mechanism for showing and hiding error messages by modifying the DOM is a task in itself.</p>
<p><strong>Why the problem is worth solving:<br />
</strong></p>
<p>Most websites contain some sort of form that requires user input &#8211; whether it be a user account signup form or an elaborate search function &#8211; and form validation can be tedious and clunky if not for a validation plugin (in jquery). While similar plugins do exist, we will be addressing certain features that the other plugins do not include.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/16434jr.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/16434jr.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/16434jr.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/16434jr.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/16434jr.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/16434jr.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/16434jr.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/16434jr.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/16434jr.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/16434jr.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/16434jr.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/16434jr.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/16434jr.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/16434jr.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=16434jr.wordpress.com&amp;blog=10601342&amp;post=19&amp;subd=16434jr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://16434jr.wordpress.com/2009/11/19/part-4-decide-on-the-implementation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/921ef2e6811a5a322019254801735b4d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">16434jr</media:title>
		</media:content>

		<media:content url="http://16434jr.files.wordpress.com/2009/11/jquery_image.jpg?w=300" medium="image">
			<media:title type="html">validation_example</media:title>
		</media:content>
	</item>
		<item>
		<title>Part 2: Study a language that solves a similar problem</title>
		<link>http://16434jr.wordpress.com/2009/11/19/part-3-what-features-specifically-will-your-language-support/</link>
		<comments>http://16434jr.wordpress.com/2009/11/19/part-3-what-features-specifically-will-your-language-support/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 08:30:15 +0000</pubDate>
		<dc:creator>16434jr</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://16434jr.wordpress.com/2009/11/21/part-3-what-features-specifically-will-your-language-support/</guid>
		<description><![CDATA[We studied a similar implementation of form validation, done in javascript (linked at http://developer.apple.com/internet/webcontent/validation.html). This validation script is essentially a javascript function that checks for correct input of username, password, email, etc. Below is an example of the code that checks for passwords: function checkPassword (strng) { var error = ""; if (strng == "") [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=16434jr.wordpress.com&amp;blog=10601342&amp;post=18&amp;subd=16434jr&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>We studied a similar implementation of form validation, done in javascript (linked at http://developer.apple.com/internet/webcontent/validation.html). This validation script is essentially a javascript function that checks for correct input of username, password, email, etc.</p>
<p>Below is an example of the code that checks for passwords:</p>
<pre>function checkPassword (strng) {
 var error = "";
 if (strng == "") {
    error = "You didn't enter a password.\n";
 }
    var illegalChars = /[\W_]/; // allow only letters and numbers
    if ((strng.length &lt; 6) || (strng.length &gt; 8)) {
       error = "The password is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
      error = "The password contains illegal characters.\n";
    }
<pre>else if (!((strng.search(/[a-z]+/) &gt; -1)
  &amp;&amp; (strng.search(/[A-Z]+/) &gt; -1)
  &amp;&amp; (strng.search(/[0-9]+/) &gt; -1))) {
  error = "The password must contain at least one
    uppercase letter, one lowercase letter,
    and one numeral.\n";
  }</pre>
</pre>
<p>The above code essentially limits password creation to be a specific subset of the language of all strings. In particular, the first few lines of code checks that the password is not the empty string (i.e. a passowrd must be entered into the form), while the next two &#8216;if&#8217; blocks ensures that the password is between 6-8 characters long and does not contain any whitespaces or underscores. In the last &#8216;if&#8217; block, the code searches the input with regexes to specify the password to contain at least one lowercase letter, one uppercase letter, and one digit.</p>
<p><strong>The implementation</strong></p>
<p>All the code is in a file called validate.js, which can be called by an HTML &#8216;script&#8217; tag at the top for the webpage with the form in it. The main function is shown below:</p>
<pre>function checkWholeForm(theForm) {
    var why = "";
    why += checkEmail(theForm.email.value);
    why += checkPhone(theForm.phone.value);
    why += checkPassword(theForm.password.value);
    why += checkUsername(theForm.username.value);
    why += isEmpty(theForm.notempty.value);
    why += isDifferent(theForm.different.value);
    for (i=0, n=theForm.radios.length; i&lt;n; i++) {
        if (theForm.radios[i].checked) {
            var checkvalue = theForm.radios[i].value;
            break;
        }
    }
    why += checkRadio(checkvalue);
    why += checkDropdown(theForm.choose.selectedIndex);
    if (why != "") {
       alert(why);
       return false;
    }
return true;
}</pre>
<p>This function acts as a wrapper function which calls the subfunctions, each of which performs checks on a field (the example above described checkPassword(), which was one such subfunction). For instance, the username field on the webpage would be checked by the checkUsername() function, which simply checks that the username is not the empty string. Some of these subfunctions, such as checkUsername(), checkRadio(), and checkDropdown() were pretty straightforward &#8211; regular expressions were used to match the input to the appropriate specifications. For checkPhone() (code shown below), there was an additional library function call to strip parentheses, spaces, and dots from phone numbers:</p>
<pre>var stripped = strng.replace(/[\(\)\.\-\ ]/g, '');
//strip out acceptable non-numeric characters
if (isNaN(parseInt(stripped))) {
   error = "The phone number contains illegal characters.";
}
<pre>if (!(stripped.length == 10)) {
	error = "The phone number is the wrong length.
	  Make sure you included an area code.\n";
}</pre>
</pre>
<p>The implementation does have its limitations. For example, the checkEmail() function does not check for email addresses that are RFC-compliant (this would require much more additional code). Furthermore, the code provides no support for AJAX requests, such that url&#8217;s could only be checked for correct formatting, but not existence. Also, this particular implementation was clunky in that each field check was hardcoded in javascript and there was no leeway for flexibility in the formatting of the fields &#8211; this resulted in code that was hard to reuse or update.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/16434jr.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/16434jr.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/16434jr.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/16434jr.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/16434jr.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/16434jr.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/16434jr.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/16434jr.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/16434jr.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/16434jr.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/16434jr.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/16434jr.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/16434jr.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/16434jr.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=16434jr.wordpress.com&amp;blog=10601342&amp;post=18&amp;subd=16434jr&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://16434jr.wordpress.com/2009/11/19/part-3-what-features-specifically-will-your-language-support/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/921ef2e6811a5a322019254801735b4d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">16434jr</media:title>
		</media:content>
	</item>
	</channel>
</rss>
