Bypass parsley.js localization catalog and use gettext() in js - javascript

I'm using parsley.js for client-side validation - so far so good!
I'm using transifex to store messages for localization. I would like to find a way to use something like gettext() in the javascript for message translation instead of the parsley catalogs. What is the correct way to do this? I've tried updating the english (default) messages and it doesn't seem to work. I'm new to Parsleyjs so forgive me if I'm asking an obvious question but I can't figure it out.
This is not working (from parsley.js):
Parsley.addMessages('en', {
defaultMessage: gettext('This field seems to be invalid.'),
...

You could override window.Parsley.getErrorMessage to suit your needs.

Related

Ace editor custom error checking

I created a new language mode in my editor with a few keywords: Ben, Tom, Brian and operands: AND OR ( ). Also, I need a custom error checker. I tried to change json worker which I have been inlcuded in my mode.
Everything I need is this: (Ben AND TOM) OR Brian - this is correct, everything else, like undefined keywords or incorecct syntax like BEN AND AND TOM, or BEN AND OR TOM- should treat as error. Does anyone have some idea?
There is no easy way to do this.
You need to create a parser for your language to detect errors and send locations to ace. There are some libraries that can help you with this. e.g http://lakhin.com/projects/papa-carlo/demo/, but even with that, it's not a trivial task

Parsely.js override default validation messages

Does anyone here know how you can override validation messages during setup.
I would like to be able to during setup $('form').parsley() to change/define validation messages messages for lets say:
data-parsley-required-message ="some relevant custom message"
I want this to be assigned to all validations so if the field is set to required it will display the custom message as default.
Thanks in advance 8-)
Look in the documentation for window.ParsleyUI.updateError(parsleyInstance, name, message);.
This is assuming version 2, if you are still on 1.X let me know and I will amend the answer.

Zend Framework Date Time Picker

I'm a real newbie in programming and finally got the ZendX Jquery to work. However, I would like to include a date time picker, and found an option at http://www.binpress.com/app/zfdatetimepicker/85 . However, the documentation is not complete and I would really want to set it up correctly. Can anyone help me with the steps required to do so? I tried setting it up and got the error " Object doesn't support property or method 'datetimepicker'". Thanks.
It sounds like you need to include the jquery UI script files. Looking at his demo, it is pulling in jQuery UI 1.8.21 from jquery's 'code' servers. I also know that without the UI component included, you will get the error message Object doesn't support property or method 'datepicker' when you do something like $('#myDate').datepicker. So I'm assuming you're just missing the correct script includes.
I've not used zend-framework at all, so I might be missing something on that side.

Eclipse: Type mismatch: cannot convert from String[] to any

Eclipse is complaining about my JavaScript code:
As fas as I can tell, the code is working fine. What do I have to change to get rid of the warning?
The semantic validator (despite it's failings, like this one) actually has a lot of uses. For instance, it can tell you when you've got a variable that's not being used anywhere (eg. because you have a typo in the variable's name).
If you don't want to see that error message, but you still want to keep semantic validation on, you can use this hack:
var textArray = 0 || [ ...
it's a little ugly, and your non-Eclipse-using co-workers may not like it, but at least it gives you a way to ditch the warning and still have the benefits of the validator.
A similar hack (if you don't like the first one, or if you're a big Douglas Crockford fan) that will also work is:
var textArray;
textArray = [ ...
Seems to be a bug of WTP , more specifically of the JS Validator component which is by default configured to "Enable JavaScript semantic validation".
Try to turn off the semantic validation from preferences page.

jQuery plugin: Validation can't be customized without setting all fields to 'required'?

I've spent the day looking at jQuery plugin: Validation by Jörn Zaefferer. I notice that it works fine as long as you call the validate() method without options. In my little squalid world, as soon as I add options, like errorPlacement, I notice that validation ignores form fields that are not marked required. I also notice that many, many demos mark all fields required---or do not pass options. Am I writing about anything familiar here? Or should I astral project to a parallel universe?
Note: This is to close the question out and provide info to resolve this to the next person finding the question since the OP has resolve the issue.
If there are any errors in the options, it will act the same as ignoring the fields, this isn't the validation plugin behavior per se, but rather how javascript works overall...any errors and it blows up (in mosts cases).
Double check all your options and use either Chrome's tools or FireBug to see if there are any script errors at all. Judging from your question, this seems the most likely culprit, fixing any errors in your options/errorPlacement will eliminate the onstacle in making the validation plugin work.
Also for testing, it's very helpful to use the debug option on the validation plugin, like this:
$("form").validate({
//other options
debug: true
});
This prevents the form from actually submitting, allowing you to tweak the validation much faster.

Categories