custom item form (e.g. using jQuery)

More
12 years 6 months ago #33283 by brandonking
Hello,

I am trying to add jQuery validation in item submission form but it is not working. Does anyone use jQuery validation in item submission form with success?

Regards

Please Log in or Create an account to join the conversation.

More
12 years 6 months ago #33285 by ggppdk
This is not dependent to jQuery so i changed the title of your initial post, but rather how to add one more custom validator handler to our form validator object without hacking our validation.js file

Maybe try adding your handler to the existing FLEXIcontent validator object:

1. your form input/select form field should have class: validate-myvalidateclass

2. Add this php code at appropriate place
Code:
static $js_validation_added = false; if ( !$js_validation_added ) { $js = " window.addEvent('domready', function(){ document.formvalidator.setHandler('username', function (value) { // do so tests some_true_false_result = ...; return some_true_false_result; } ); }); "; JFactory::getDocument()->addScriptDeclaration($js); $js_validation_added = true; }


NOTE this must be loaded after validation.js file has been loaded

I have created a FAQ article, so test and post back here with results to update or unpublish the article


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
12 years 6 months ago #33288 by ggppdk
A correction (i updated original post ...)
class name in the field needs to be:

validate-myvalidateclass

and not

myvalidateclass


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
12 years 6 months ago #33292 by brandonking
Hello,

I am confused about where to edit. :oops:

1) You mean I have to add validation class into e.g. text.php?
2) Do I have to add the code you have stated into form.php?

For example, I want to validate particular text field whether its value is number or not.
The validation code would be like below.
Code:
$(document).ready(function() { $('#adminForm').validate({ rules : { custom_field109_0: { required: true, number: true, maxlength: 5 } }, messages: { custom_field109: { required: 'Required', maxlength: $.format('{0}aaa') } } }); });

3) Could please explain me where to add my validation code?

Best Regards,
Brandon

Please Log in or Create an account to join the conversation.

More
12 years 6 months ago #33293 by ggppdk
1. The code should be as i gave it to you, place you custom code inside there !!

2. About the CSS class validate-myvalidateclass
it must be in the input field like this
<input ... class="... validate-myvalidateclass" />
you need to modify your plugin file inside function:
onDisplayField() , to add it


3. You can add the js code almost everywhere
a. in your custom FLEXIcontent plugin file myfield.php (inside the onDisplayField() function, or
b. anywhere in FLEXIcontent template or
c. other place


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.256 seconds
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Save