reisve
05-19-2013, 09:09 AM
Hi.
Can someone help me finding why the jQuery is not validating the form on the following page? I'm new to jQuery...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Negócios Angola</title>
<base href="http://root.com/divdev/">
<meta http-equiv="Content-Type" content="text/html; charset=Western (ISO-8895-1)" />
<link rel="stylesheet" type="text/css" href="css/backend.css">
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script>
<script>
// When the browser is ready...
$(function() {
// Setup form validation on the #addcat element
$("#addcat").validate({
// Specify the validation rules
rules: {
categories: "required",
newcat: "required",
catdesc: "required"
},
// Specify the validation error messages
messages: {
categories: "Tem que seleccionar a categoria parente",
newcat: "Introduza nova categoria",
catdesc: "Descreva a categoria"
},
submitHandler: function(form) {
form.submit();
}
});
</script>
</head>
<body>
<div class="searchspace">
<div class = "search">
<form class = "searchform">
<input class = "searchfield" type = "text" value = "Procurar..." onfocus = "if (this.value == 'Procurar...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Procurar...';}" />
<input class = "searchbutton" type = "button" value = "GO" />
</form>
</div>
</div>
<div class="infospace">
INFO LINE </div>
<div class="leftspace">
<div class = "menu">
<ul class="sexypanels">
<li><a href="admin/addcat.php">» Adicionar Categorias</a></li>
<!--
<li><a href="http://www.dynamicdrive.com/style/" >» CSS Examples</a></li>
<li><a href="http://www.javascriptkit.com/jsref/">» JavaScript Reference</a></li>
<li><a href="http://www.javascriptkit.com/domref/">» DOM Reference</a></li>
<li><a href="http://www.cssdrive.com">» CSS Drive</a></li>
<li class="lastitem"><a href="http://www.codingforums.com/">» Coding Forums</a></li>
-->
</ul>
</div> </div>
<div class="middlespace">
<div class = "addcatheader">
Adicionar novas Categorias </div>
<div class = "addcat">
<form id = "addcat" method="post" action = "admin/addcat.php">
<table width = "100%" border = "0">
<tr>
<td width = "40%" align = "right" valign = "top"><label for="categories">Categoria Parente:</label></td>
<td width = "60%">
<select id = "categories" name = "cat_parent">
<option value = 0>Topo</option><option value = 2> |___Tecnologias da Informação</option><option value = 3> | |___Informática</option><option value = 5> | | |___Venda de Computadores </option><option value = 6> | | |___Consumiveis</option><option value = 4> | |___Infrastructuras</option> </select>
</td>
<tr>
<td colspan = "2"> </td>
</tr>
<tr>
<td align = "right" valign = "top"><label for="newcat">Nome da Categoria:</label></td>
<td><input id = "newcat" type ="text" name = "cat_name"></td>
</tr>
<tr>
<td colspan = "2"> </td>
</tr>
<td align = "right" valign = "top"><label for="catdesc">Descrição da Categoria:</label></td>
<td><textarea id = "catdesc" name = "cat_desc"></textarea></td>
</tr>
<tr>
<td colspan = "2"> </td>
</tr>
<tr>
<td colspan = "2" align = "center"><button id = "submit" type = "submit">Adicionar</button></td>
</tr>
</table>
</form>
</div>
</div>
<div class="footer">
<div class = "footerdiv">
Negócios Angola - © 2012 <br />
<a href=href="mailto:admin@negiciosangola.com" style = "text-decoration: none; color: #ffffff";>Contactar o Webmaster</a>
</div>
</div>
</body>
</html>
Thank You
Can someone help me finding why the jQuery is not validating the form on the following page? I'm new to jQuery...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Negócios Angola</title>
<base href="http://root.com/divdev/">
<meta http-equiv="Content-Type" content="text/html; charset=Western (ISO-8895-1)" />
<link rel="stylesheet" type="text/css" href="css/backend.css">
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script>
<script>
// When the browser is ready...
$(function() {
// Setup form validation on the #addcat element
$("#addcat").validate({
// Specify the validation rules
rules: {
categories: "required",
newcat: "required",
catdesc: "required"
},
// Specify the validation error messages
messages: {
categories: "Tem que seleccionar a categoria parente",
newcat: "Introduza nova categoria",
catdesc: "Descreva a categoria"
},
submitHandler: function(form) {
form.submit();
}
});
</script>
</head>
<body>
<div class="searchspace">
<div class = "search">
<form class = "searchform">
<input class = "searchfield" type = "text" value = "Procurar..." onfocus = "if (this.value == 'Procurar...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Procurar...';}" />
<input class = "searchbutton" type = "button" value = "GO" />
</form>
</div>
</div>
<div class="infospace">
INFO LINE </div>
<div class="leftspace">
<div class = "menu">
<ul class="sexypanels">
<li><a href="admin/addcat.php">» Adicionar Categorias</a></li>
<!--
<li><a href="http://www.dynamicdrive.com/style/" >» CSS Examples</a></li>
<li><a href="http://www.javascriptkit.com/jsref/">» JavaScript Reference</a></li>
<li><a href="http://www.javascriptkit.com/domref/">» DOM Reference</a></li>
<li><a href="http://www.cssdrive.com">» CSS Drive</a></li>
<li class="lastitem"><a href="http://www.codingforums.com/">» Coding Forums</a></li>
-->
</ul>
</div> </div>
<div class="middlespace">
<div class = "addcatheader">
Adicionar novas Categorias </div>
<div class = "addcat">
<form id = "addcat" method="post" action = "admin/addcat.php">
<table width = "100%" border = "0">
<tr>
<td width = "40%" align = "right" valign = "top"><label for="categories">Categoria Parente:</label></td>
<td width = "60%">
<select id = "categories" name = "cat_parent">
<option value = 0>Topo</option><option value = 2> |___Tecnologias da Informação</option><option value = 3> | |___Informática</option><option value = 5> | | |___Venda de Computadores </option><option value = 6> | | |___Consumiveis</option><option value = 4> | |___Infrastructuras</option> </select>
</td>
<tr>
<td colspan = "2"> </td>
</tr>
<tr>
<td align = "right" valign = "top"><label for="newcat">Nome da Categoria:</label></td>
<td><input id = "newcat" type ="text" name = "cat_name"></td>
</tr>
<tr>
<td colspan = "2"> </td>
</tr>
<td align = "right" valign = "top"><label for="catdesc">Descrição da Categoria:</label></td>
<td><textarea id = "catdesc" name = "cat_desc"></textarea></td>
</tr>
<tr>
<td colspan = "2"> </td>
</tr>
<tr>
<td colspan = "2" align = "center"><button id = "submit" type = "submit">Adicionar</button></td>
</tr>
</table>
</form>
</div>
</div>
<div class="footer">
<div class = "footerdiv">
Negócios Angola - © 2012 <br />
<a href=href="mailto:admin@negiciosangola.com" style = "text-decoration: none; color: #ffffff";>Contactar o Webmaster</a>
</div>
</div>
</body>
</html>
Thank You