chuzymatics
chuzymatics

Reputation: 39

Validating forms involving textarea

I am trying to use jquery technology to validate web forms(I am actually learning now). After downloading and referencing the files in my code, TEXTAREA stubbornly refused to be validated even after assigning it REQUIRED class attribute. Pls could someone help. Apologies, if it's trivial. Here's the code:

<script type ="text/JavaScript" src = "jquery.js"></script>
<script type ="text/JavaScript" src ="jquery.validate.js"></script>
<script type ="text/JavaScript">
$(document).ready(function(){
 $("#reg").validate(); 
})// end of ready()

From Code:

<form id = 'reg' method ='post' action =''>
<label for 'username'>User Name **</label>
 <input type ='text' name ='username' id ='usN' class = 'required' title = "Enter Your name"><br/>
 <label for 'Address'> Address **</label>
<input type ='text' id ='addr' class = 'required' title = "Enter Your Address"><br/>
<label for 'comment'>Comment Below **</label>
br/> <textarea id ='comm' rows =5, cols = 18 class ='required' title = 'Make a comment'></textarea><br/>
<input type ='submit' id = 'button1' value = 'SEND'>
</form>

Upvotes: 0

Views: 39

Answers (1)

GUL
GUL

Reputation: 1195

You have to add a unique name attribute to each input/textarea element.

Markup recommendations

The name attribute is required for input elements, the validation plugin doesn't work without it.

Upvotes: 3

Related Questions