Forums de discussion
Client Side Web Form Validation Help
Joshua Bertrand, modifié il y a 11 années.
Client Side Web Form Validation Help
New Member Publications: 17 Date d'inscription: 01/05/12 Publications récentes
My organization is using 6.1 EE with the "Web Form" portlet on several of our sites. We are needing to add validation scripts to our forms to ensure that a Phone Number holds numeric values and is at least 8 characters and that email address's must include @ symbol.
My attempts for the javascript code have not worked (although I am still in my early stages of learning javascript).... my question is.. are there any javascript examples out there that I can copy for this? I have been looking for the last hour and have been unsuccessful in finding anything that works.
Thank you for any help you can provide.
My attempts for the javascript code have not worked (although I am still in my early stages of learning javascript).... my question is.. are there any javascript examples out there that I can copy for this? I have been looking for the last hour and have been unsuccessful in finding anything that works.
Thank you for any help you can provide.
Vishal Panchal, modifié il y a 11 années.
RE: Client Side Web Form Validation Help
Expert Publications: 289 Date d'inscription: 20/05/12 Publications récentes
Hi Joshua Bertrand,
Please take a look at this link
It will surely help you to learn basic validations using javascript as well as to get your desired..!!
Thanks & Regards,
Vishal R. Panchal
Please take a look at this link
It will surely help you to learn basic validations using javascript as well as to get your desired..!!
Thanks & Regards,
Vishal R. Panchal
Joshua Bertrand, modifié il y a 11 années.
RE: Client Side Web Form Validation Help
New Member Publications: 17 Date d'inscription: 01/05/12 Publications récentes
Thank you for the link. It was very helpful in understand the correct way to code a validation script. However, applying this to the Web Form portlet has still been unsuccessful and my form still submits when invalid characters are presented. Does anyone just have code that they use that you wouldn't mind providing?
Thank you.
Thank you.
Shinn Lok, modifié il y a 11 années.
RE: Client Side Web Form Validation Help
Junior Member Publications: 89 Date d'inscription: 14/01/11 Publications récentes
Phone Number:
Email Address:
if(!/\D/.test(currentFieldValue) && currentFieldValue.length >= 8)
return true
else return false;
Email Address:
if (currentFieldValue.indexOf("@")>=0)
return true;
else return false;
Hitoshi Ozawa, modifié il y a 11 années.
RE: Client Side Web Form Validation Help
Liferay Legend Publications: 7942 Date d'inscription: 24/03/10 Publications récentesif(!/\D/.test(currentFieldValue) && currentFieldValue.length >= 8)
Any reason to using (!/\D/ instead of /\d/ and just use .search instead of .test and just specifiy number of digits with [8] instead of using length?
if (currentFieldValue.indexOf("@")>=0)
This is a very primitive validation. Should use regular expression so it can be expanded to also test if the domain contains "." and if the left side and right side of "@" at least contain some character. There also may have been some restriction on the left side starting with a character. I think there was a validation check using regular expression in liferay already and it may just be a matter of copying it.
Joshua Bertrand, modifié il y a 11 années.
RE: Client Side Web Form Validation Help
New Member Publications: 17 Date d'inscription: 01/05/12 Publications récentes
My form is still submitting with this code... here is a screen shot... is there anything I am doing wrong?
Pièces jointes:
João Gomes, modifié il y a 11 années.
RE: Client Side Web Form Validation Help
New Member Publications: 9 Date d'inscription: 12/03/13 Publications récentes
I have the exact same problem.
The validation script does not run.
How do i fix this, does it needs the script tags? Already tried and didnt work.
Help please.
The validation script does not run.
How do i fix this, does it needs the script tags? Already tried and didnt work.
Help please.
Rajeev K, modifié il y a 10 années.
RE: Client Side Web Form Validation Help
Regular Member Publications: 214 Date d'inscription: 19/06/09 Publications récentesJoão Gomes:
I have the exact same problem.
The validation script does not run.
How do i fix this, does it needs the script tags? Already tried and didnt work.
Help please.
Same problem.
The javascript code never gets called. Simple alert() is also not coming.
Whats could be the problem. Did you get it resolved?
Neetu Mishra, modifié il y a 10 années.
RE: Client Side Web Form Validation Help
Junior Member Publications: 75 Date d'inscription: 21/05/12 Publications récentes
Hi Joshua,
Below is the code for Email validation:
var isEmail = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if(currentFieldValue.search (isEmail) == -1 && currentFieldValue != '') {
return false;
} else {
return true;
}
Hope this will help you.
Regards,
Neetu
Below is the code for Email validation:
var isEmail = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if(currentFieldValue.search (isEmail) == -1 && currentFieldValue != '') {
return false;
} else {
return true;
}
Hope this will help you.
Regards,
Neetu
Vishal Panchal, modifié il y a 11 années.
RE: Client Side Web Form Validation Help
Expert Publications: 289 Date d'inscription: 20/05/12 Publications récentesJoshua Bertrand:
Thank you for the link. It was very helpful in understand the correct way to code a validation script. However, applying this to the Web Form portlet has still been unsuccessful and my form still submits when invalid characters are presented. Does anyone just have code that they use that you wouldn't mind providing?
Thank you.
Hi Joshua Bertrand,
please find the file attached .
it is a sample code what u exactly want.
Please let me know if any inputs required..!!
Thanks & Regards,
Vishal R. Panchal
Pièces jointes:
Rajeev K, modifié il y a 10 années.
RE: Client Side Web Form Validation Help
Regular Member Publications: 214 Date d'inscription: 19/06/09 Publications récentesVishal Panchal:
Joshua Bertrand:Thank you for the link. It was very helpful in understand the correct way to code a validation script. However, applying this to the Web Form portlet has still been unsuccessful and my form still submits when invalid characters are presented. Does anyone just have code that they use that you wouldn't mind providing?
Thank you.
Hi Joshua Bertrand,
please find the file attached .
it is a sample code what u exactly want.
Please let me know if any inputs required..!!
Thanks & Regards,
Vishal R. Panchal
The Javascript function never gets called. What could be the problem?
Stefan Hüttenrauch, modifié il y a 9 années.
RE: Client Side Web Form Validation Help
New Member Publications: 5 Date d'inscription: 06/04/11 Publications récentes
Hi there,
let me point you to this link: http://stackoverflow.com/questions/11844221/liferay-webform-portlet-field-validation
...
Stop Tomcat
Go to APPLICATION_SERVER_ROOT_DIRECTORY/webapps/web-form-portlet/WEB-INF/classes directory
Open portlet.properties and change "validation.script.enabled" property from "false" to "true"
...
I would say: Download the source code and correct the portlet.properties file. Then deploy your own version of the web form portlet. I haven't found a switch in the portlet configuration to turn javascript validation on without modifying the properties file.
A hint in the configuration screen would have been nice ;-)
Regards
Stefan
let me point you to this link: http://stackoverflow.com/questions/11844221/liferay-webform-portlet-field-validation
...
Stop Tomcat
Go to APPLICATION_SERVER_ROOT_DIRECTORY/webapps/web-form-portlet/WEB-INF/classes directory
Open portlet.properties and change "validation.script.enabled" property from "false" to "true"
...
I would say: Download the source code and correct the portlet.properties file. Then deploy your own version of the web form portlet. I haven't found a switch in the portlet configuration to turn javascript validation on without modifying the properties file.
A hint in the configuration screen would have been nice ;-)
Regards
Stefan