MVCControlsToolkit and Validation - javascript

Today I installed the MVC3ControlsToolkit from NuGet, and proceeded to add a a DateTimeFor control to a Scaffolding generated page. I only changed one line of code, but the page was no longer visible, and an exception was thrown, saying validation was happening twice.
If I set UnobtrusiveJavaScriptEnabled to false in my Web.config, I can view the page. Funny thing is that if I restore the page to it's previous state (ie. default config) the error persists.
The error I get is: "Validation type names in unobtrusive client validation rules must be unique. The following validation type was seen more than once: required"
If anyone can shed some light on this, I'd really appreciate it.

Related

Generic exception submitting form via JavaScript

I am moving an application from JBoss 7.1.q to WildFly. Parts of the navigation are done with by creating a form in JavaScript and submitting it via the submit method. All of these calls still work with the exception of one.
Instead of navigating to the page, I get a message of
A Generic Exception Occurred while accessing this page.
I grepped through the code to see if someone had created a window.onerror function to catch exceptions but could not find one. Even more odd, I added one to the js page and it failed to catch the exception.
I have waded through the JavaScript with Firebug and Chrome dev tools and from what I can see, everything looks to be OK, but clearly it is not.
I know it is not much to go on. I am looking for ideas for the next steps to triage this issue. I also find it curious that this problem did not appear until the move to WildFly but I have no clue how that could cause this issue - maybe the form posting is more strict?
Any ideas?

Tests fail on travis, which pass local

My tests which turn green local, are getting red on travis. It's about this code:
And I change the year to "nineteen-ninenty-seven" # features/step_definitions/application_steps.rb:9
And I attempt to save the changes # features/step_definitions/application_steps.rb:17
Then I should see a message indicating that the data is invalid # features/step_definitions/application_steps.rb:26
expected to find text "Value must be of type integer." in "Provider configurations root name artist year" (RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/application_steps.rb:27:in `/^I should see a message indicating that the data is invalid$/'
features/editing_resources.feature:52:in `Then I should see a message indicating that the data is invalid'
This is in my support/capybara.rb
require 'capybara/cucumber'
require 'capybara/poltergeist'
Capybara.app = App.new
Capybara.javascript_driver = :poltergeist
Capybara.default_wait_time = 10
It's about this code:
When(/^I change the year to "(.*?)"$/) do |year|
find('input[name="root[year]"]').set year
end
When(/^I attempt to save the changes$/) do
find('input[type=submit]')
end
Then(/^I should see a message indicating that the data is invalid$/) do
expect(page).to have_content('Value must be of type integer.')
end
The problem:
When I run the tests local, they turn green. I debugged it there. I'm for sure that the code works well. The fields exist and get filled with the right data. When I use pry in my local tests on the point that I expect the message, I 'source' (or html), and I can find the text myself. On travis/ubuntu this doesn't work. I can confirm this doesn't work, cause I contacted Travis and they gave me a VM for a day where I duplicated the problem.
To solve it, I tried multiple things, I increased waiting time, tried selenium/webkit and selenium with chrome/firefox. They al work local, but I can't get them working properly on travis.
What I want to achieve is that the test validates if the user see's a messages which is getting created when a field isn't filled properly (text in integer field in this example).
The message is created by Json editor. https://github.com/jdorn/json-editor
And looks like this in code:
<small class="error">Value must be of type integer.</small>
A logic explanation in my opinion: in travis, the dom doesn't get the newest version which should load after an activity get's executed (like fill_in or set) and local this does work.
I hope somebody has an explanation and a solution.
Although I can't provide an answer for your exact problem, I can try to help you debug the issue with the information you provided.
Regarding Poltergeist:
Poltergeist allows you to take screenshots at specific points in your test
Depending on your tests, one thing that you may need is some fonts. If you're getting errors on a CI that don't occur during development then try taking some screenshots
I would try using page.save_screenshot before and after the points you identified and see what the differences are between local/travis.
EDIT: There is also a gem for capybara that takes screenshots whenever a test fails. Find more info here: Capybara-Screenshot

flowplayer html validation

Ok, Im trying to rebuild a clients website thats long over due for cleanup on the backend and under the hood. This client uses flowplayer for most of the videos seen on any of there sites, and while attempting to validate my code via w3c validator I notice that the validator is throwing 2 errors both pertaining to flowplayer in this case.
http://validator.w3.org/check?uri=http%3A%2F%2Fv2.newyorkbarshow.com%2Fhome&charset=%28detect+automatically%29&doctype=Inline&group=0&user-agent=W3C_Validator%2F1.3
I am using the latest flowplayer out, and following there example (which I don't know if that validates either). So I am wondering if it doesn't validate out of the box, if anyone happens to know a means of correcting it so it will validate.
You need to add data attribute with value "/static/imgs/static/VidAd4BarShow.swf" in your object tag.
note : I see this happens before flow player executes anything within your source...

Ideas on why JS causes rails validations to be ignored

I have a rails application that uses $('form').submit(), however if it fails the validation once and then it is clicked again it completely ignores the validations and generates a routing error. Now, If I use the regular button it does not do this unless the JQuery submit exists with it. Why do you think that is?
Update: JQuery finds the form values looking for anything within the <form> tags.
Okay the problem was not related to the JavaScript at all. What was happening is a variable was getting a value of nil causing a routing error for the path. Adding a check for nil and reassigning it if it is fixed it.

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