Primefaces client side validation

UI Components for JSF
Post Reply
Ovoxo
Posts: 8
Joined: 06 Jan 2016, 18:30

09 Apr 2016, 19:37

Hi there,

I've got a question. I'd like to use Client side Validation for my Primefaces Project. Right now I just use Server side Validation which works good.
I'd like to validate just min. and max for Input.

I found this component which works well but I just don't like the Messages it throws.

Code: Select all

[/<f:validateLength minimum="2" />code]

Now I'd like to know if there is a easy way to Change this message or do I have another Option to validate on Client side.

Would you say I Need both Client and Server side Validation or is just Server side enough?


hsntpn
Posts: 15
Joined: 18 Mar 2016, 21:24

17 Jun 2016, 10:05

if you want to use validation with javascript use as

Code: Select all

<p:inputText value="#{---your beans data---}"
							onkeyup="var pos=this.selectionStart;
									var size = this.value.length;														
             						this.value=this.value.replace(/[^0-9]+/g, '');
             						if (this.value.length > 10) this.value=this.value.substring(0,10);
             						if (size > this.value.length)
             							{this.selectionStart = pos-1; this.selectionEnd = pos-1;}
             						else
             							{this.selectionStart = pos; this.selectionEnd = pos;}"
							size="24" />

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 59 guests