Forums de discussion

How can I add validation on an AUI form?

Francis Zabala, modifié il y a 12 années.

How can I add validation on an AUI form?

New Member Publications: 13 Date d'inscription: 01/02/12 Publications récentes
Hello friends,

I am having trouble adding validation on an AUI form. I am able to generate the form without the problems except for the validation. The jQuery validation needs the "required" css class to be added in the <input> html tag and because I am using a taglib as I am too lazy to create my own form by hand, I could not add the "required" css class in the generated <input> tag. The cssClass parameter for the <aui:/> tag only adds the css class in the <span> tag encompassing the <input> tags when it is generated.

My question is, is there a way to add the "required" class when the <input> tag is generated? Or are there any better ways to do the validation except doing it server side? I don't mind overriding the ui-taglib.jar classes but I don't know how to start.
Francis Zabala, modifié il y a 12 années.

RE: How can I add validation on an AUI form?

New Member Publications: 13 Date d'inscription: 01/02/12 Publications récentes
Hello,

Here's how I fixed my problem. This is what I did so that I can use the script found, jQuery Validate


&lt;% String portletId = portletDisplay.getId(); %&gt;

  <script>
  
  $(document).ready(function(){
    $("#_<%=portletId%>_fm").validate();
  	//Below is an ugly piece of code. I just hope that someone would answer my post below
 	var element = document.getElementById("_<%=portletId%>_firstName");
	element.className= element.className + " required";
	element = document.getElementById("_<%=portletId%>_lastName");
	element.className= element.className + " required";
	element = document.getElementById("_<%=portletId%>_homeAddress");
	element.className= element.className + " required";
	element = document.getElementById("_<%=portletId%>_primaryEmail");
	element.className= element.className + " required";
	});
  </script>


It's ugly but it works. Let me know if there's a better way. Thanks!
Francis Zabala, modifié il y a 12 années.

RE: How can I add validation on an AUI form?

New Member Publications: 13 Date d'inscription: 01/02/12 Publications récentes
Uhm, ok this is really the best way to do it? Are there any one who can check this out and see if there is a better way?
thumbnail
mohammad azaruddin, modifié il y a 11 années.

RE: How can I add validation on an AUI form?

Expert Publications: 492 Date d'inscription: 17/09/12 Publications récentes
Hi
Try this AUIemoticonVALIDATOR

And AUIemoticonDROPDOWN

Regards
azhar