Discussions
Categories
Groups
Advertisement
Child Item
Home
Topics
Technology & Internet
Software & Web Development
Design
form validation
vodkadub
Anyone know of an easy to validate a form using javascript?
Find more posts tagged with
Quick Links
All Categories
Recent Posts
Activity
Unanswered
Groups
Best Of
Advertisement
Advertisement
Comments
marcphisto
http://jquery.com
+
http://bassistance.de/jquery-plugins/jquery-plugin-validation/
Should sort you out.
vodkadub
Im looking for something hand coded, thanks anyway
Evil Phil
There really isn't a way to use javascript for form validation unless is server side javascript.
Eoin
As Evil Phil says, server side is the place to do it. Doing it client side should only be for the purposes of usability, and not relied on by the site.
That said, here's a quick example you can work from:
[html]
<script type="text/JavaScript">
function checkForm()
{
if (document.getElementById("txtName").value == "")
{
alert("Please enter your name");
return false;
}
return true;
}
</script>
<form name="frmTest" action="this.asp" method="post" onsubmit="return checkForm()">
Name: <input type="text" name="txtName" id="txtName" value="" />
<input type="submit">
</form>
[/html]