<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<title>Use jQuery to validate the name and comment fields in sNews</title>
<link>http://www.mdj.us/</link>
<description>Use this little snippet of jQuery to provide basic user validation for the default required fields in your sNews comment forms.</description>
<language>en</language>
<item>
<title>Matt</title>
<description></description>
<link>http://www.mdj.us/web-development/ajax-javascript/use-jquery-to-validate-the-name-and-comment-fields-in-snews/#comment-1647</link>
<pubDate>Sun, 01 Apr 2012 20:33:02 +0000</pubDate>
<content:encoded><![CDATA[You need jquery to be loaded before my script. <br />
<br />
This doesn't affect the sNews comment function, as it's javascript it all runs client-side. Basically it just checks the fields &amp; if there's an error it shows the alert &amp; prevents the form from being submitted. <br />
<br />
Nope, no changes needed to any code inside sNews. <br />
<br />
I'm puzzled now, I will definitely have to install a copy of sNews 1.6 &amp; investigate.]]></content:encoded>
</item>
<item>
<title>keyrocks</title>
<description></description>
<link>http://www.mdj.us/web-development/ajax-javascript/use-jquery-to-validate-the-name-and-comment-fields-in-snews/#comment-1646</link>
<pubDate>Sun, 01 Apr 2012 16:41:45 +0000</pubDate>
<content:encoded><![CDATA[No, nothing online. I develop on localhost. A few questions:<br />
<br />
1) Do we need jquery 1.71 available, or the script alone?<br />
....... I've tested both ways, and with the script in the &lt;head&gt; rather than importing from outside index.php. No difference.<br />
<br />
2) How would function comment know to over-ride the default message and use the script to show error messages as an overlay?<br />
...... Just typing 1 character in the textarea and submitting the form just invokes the default sNews error message - &quot;Your comment was not sent. Possible reasons:&quot; which are generated in the function by the language values for $commentStatus and $commentReason. Following that, I'm redirected back to the page viewed before submitting.<br />
<br />
3) Are any changes required to function comment?]]></content:encoded>
</item>
<item>
<title>Matt</title>
<description></description>
<link>http://www.mdj.us/web-development/ajax-javascript/use-jquery-to-validate-the-name-and-comment-fields-in-snews/#comment-1645</link>
<pubDate>Sat, 31 Mar 2012 15:25:42 +0000</pubDate>
<content:encoded><![CDATA[I just found an sNews 1.6 install, viewed the source &amp; copied the comment form into the fiddle and it works.<br />
<br />
I've updated it.<br />
<br />
<a href="http://jsfiddle.net/mdjus/uw3ZN/" rel="nofollow">http://jsfiddle.net/mdjus/uw3ZN/</a><br />
<br />
Do you have a stock 1.6 install I could take a quick look at?]]></content:encoded>
</item>
<item>
<title>Matt</title>
<description></description>
<link>http://www.mdj.us/web-development/ajax-javascript/use-jquery-to-validate-the-name-and-comment-fields-in-snews/#comment-1644</link>
<pubDate>Sat, 31 Mar 2012 15:12:27 +0000</pubDate>
<content:encoded><![CDATA[Hmmm, I will see if I can install 1.6 sometime &amp; have a go at it. Very strange though, the field IDs in the jsfiddle are from 1.6 I thought, and that's what the jquery script checks onsubmit.]]></content:encoded>
</item>
<item>
<title>keyrocks</title>
<description></description>
<link>http://www.mdj.us/web-development/ajax-javascript/use-jquery-to-validate-the-name-and-comment-fields-in-snews/#comment-1643</link>
<pubDate>Sat, 31 Mar 2012 01:23:02 +0000</pubDate>
<content:encoded><![CDATA[Thanks Matt.<br />
I'm using the JQuery 1.5 Library and its corresponding min file, either one, same non-response.<br />
<br />
Tried replacing the js script with the jsfiddle script, the default comment form just returns the default &quot;Your comment was not sent&quot; along with the suggested problems with a back link. Tried replacing the &lt;form&gt;&lt;/form&gt; section within the default comment function with the plain HTML form from jsfiddle... nothing.<br />
<br />
I have your email and gravatar mods in another 1.7 project, so tried it with that one... no response with either.<br />
<br />
I don't need this mod... only suggested phpmyadmin check your site to see if you had it since he was looking for it, then he posted that he couldn't use it for 1.6, so I thought I'd give it a quick try.  I'm puzzled. I'm also illiterate when it comes to jscript. Cheers :-)]]></content:encoded>
</item>
<item>
<title>Matt</title>
<description></description>
<link>http://www.mdj.us/web-development/ajax-javascript/use-jquery-to-validate-the-name-and-comment-fields-in-snews/#comment-1642</link>
<pubDate>Fri, 30 Mar 2012 16:06:13 +0000</pubDate>
<content:encoded><![CDATA[Hi keyrocks,<br />
<br />
This was kind of designed to go with the email field for my gravatar mod. The default sNews install just has a URL field I think.<br />
<br />
Try the javascript (bottom left-most box) from this jsfiddle I made.<br />
<br />
<a href="http://jsfiddle.net/mdjus/uw3ZN/" rel="nofollow">http://jsfiddle.net/mdjus/uw3ZN/</a>]]></content:encoded>
</item>
<item>
<title>keyrocks</title>
<description></description>
<link>http://www.mdj.us/web-development/ajax-javascript/use-jquery-to-validate-the-name-and-comment-fields-in-snews/#comment-1641</link>
<pubDate>Fri, 30 Mar 2012 13:49:56 +0000</pubDate>
<content:encoded><![CDATA[Hi Matt:<br />
OK... so how does this work? I'm testing in a default 1.7 install offline.<br />
I have the minified script for snews-form-validate.min.js in the root/js folder, and linked to it in index.php. Jscript is working fine in my FF with other JQuery projects, but nothing appears to apply to the comment or contact form... no popups reminding the user to do anything with empty fields.<br />
<br />
What might I be missing?]]></content:encoded>
</item>
<item>
<title>Casper Driver</title>
<description></description>
<link>http://www.mdj.us/web-development/ajax-javascript/use-jquery-to-validate-the-name-and-comment-fields-in-snews/#comment-1371</link>
<pubDate>Sat, 09 Apr 2011 08:27:19 +0000</pubDate>
<content:encoded><![CDATA[nice nice thanks...]]></content:encoded>
</item>
<item>
<title>reey</title>
<description></description>
<link>http://www.mdj.us/web-development/ajax-javascript/use-jquery-to-validate-the-name-and-comment-fields-in-snews/#comment-1357</link>
<pubDate>Fri, 25 Mar 2011 00:08:16 +0000</pubDate>
<content:encoded><![CDATA[thanks........]]></content:encoded>
</item>
<item>
<title>Matt</title>
<description></description>
<link>http://www.mdj.us/web-development/ajax-javascript/use-jquery-to-validate-the-name-and-comment-fields-in-snews/#comment-1113</link>
<pubDate>Tue, 27 Apr 2010 16:57:57 +0000</pubDate>
<content:encoded><![CDATA[Code has been updated to work with the contact form as well. <br />
<br />
It will check for empty values for names and emails (very basic, no regex... and on contact page only, not for comments so it will work with my gravatar mod), as well as the message/comment text area.]]></content:encoded>
</item>
</channel>
</rss>

