Friday, April 17, 2009

Simplest example for JQuery validation

<html>

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/validate/jquery.validate.js">
</script>
<script>

$(document).ready(function(){
$("#contactForm").validate();
});
</script>


<body>
<div id="container">
<form id="contactForm" method="" action="">
<label for="cemail">E-Mail</label>
<input id="cemail" name="email" size="25" class="required email" />
<input id="number" name ="number" class="required number"/>
<input class="submit" type="submit" value="submit"/>
</form>
</div>

</body>
</html>

Thursday, April 16, 2009

Boxy/JQuery

Source
Simple stuff only.

JQuery selector and getElementById

Javascript:
document.getElementById('product_id_01')

JQuery selector:
$('#product_id_01')[0]

Wednesday, April 15, 2009

How to debug Javascript/JQuery in VS2008

1. In browser: Enable script debugging
2. In VS 2008: Run the project first. Do not set breakpoint in your document first
3. In VS 2008: Check your solution explorer on the top. You will find [script document]. Double click to open html page and set breakpoint.

Tuesday, April 14, 2009

JQuery code for inline edit

<html>
<body>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

<span class="editName">Test</span>
<input id="newName" name="editName" style="display: none" type="text" />

<script type="text/javascript">
$(function(){
$("span.editName").click(function(){
$(this).hide();
$(this).next("input#newName").show().focus();
});
});
</script>
</body>
</html>