semantic ui remote validation - javascript

I am using Semantic UI along with ASP.NET MVC. I have performed client-side validation in my registration form as described in the documentation http://semantic-ui.com/modules/form.html Now i want to validate an email in order to be unique. So i have to make an ajax request to the server (this is something i know how to do). But how can i add such a rule in Semantic UI and display a corresponding error message?

After a little search at the docs I found the behavior add errors. It works like
$('.your.ui.form').form('add errors', ['Your error string 1', 'Maybe another one?']);
However, this will only change the text in the error messages. If the error message is not displayed at that time, you will probably want to show it. Add the class 'error' to the form:
$('.your.ui.form').addClass('error');
And of course you can chain these two methods like
$('.ui.form')
.form('add errors', ['oh my error'])
.addClass('error');
Here's a fiddle

Related

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.

testing angularjs application using casperjs

When testing an Angular application using Casper I found that the binding between inputs and model didn’t seem to be happening when I filled in form fields. I used Casper’s fill method but found that the Angular form validation was rejecting any required fields as though they were still blank.
Name
Email
Subject
Message
I'm looking around to do something similar, but slightly different (my problem as yet unsolved). However while looking I came across the following article that would appear to be what you want.
http://blog.freeside.co/post/41774715101/testing-angular-forms-with-casper
Basically the fill method in casper doesn't trigger Angular's input event, so Angular doesn't do its thing and you end up with blank post data. The blog entry shows how to override the fill method with coffeescript so the event gets fired.
Hope this helps.

Any Javascript/Jquery Library To validate SQL statment?

i have a textarea in my project where users can save SQL queries but one of the requirements is to check if this query is valid or not
EXAMPLE
if user entered something like :
SELECT ** FROM EMP
this should return false and an error message just saying invalid it doesn't have to give any reasons
mainly the queries will be just select statement
NOTICE
i DON'T want to use any server side at this point
Question
Does any one knows a javascript / jquery library or plugin that have this functionality or any thing similar
i have Google this and it didn't show any thing
Thanks
Here is an example fiddle using the JS SQL Parser:
http://jsfiddle.net/Hb6az/
The parser will throw an error if it hits something unexpected, so you have to wrap your checking code in a try {} catch(error) {} block.

Where does rails log errors in javascript?

I'm fairly new to Ruby on Rails so sorry if the answer is obvious, I couldn't find anything via search. Right now I have my view rendering _box.js.erb which simply draws a box. Inside _box.js.erb, which works correctly under normal circumstances, I introduce a simple syntax error like an unmatched parenthesis. When I load the webpage, my box doesn't show up. I look in logs/development.logs and it has no mention of my javascript syntax error. Is this error being caught somewhere? If so, how can I display it?
The error occurs on the client, not the server, so ROR cannot log it.
If you're using Firefox, install Firebug. Other browsers have JavaScript consoles, usually opened by pressing F-12 or looking on the "developer" options on the application menus.
You could also create a controller to accept javascript errors, so when there's a client side error you can just send it to a javascript error collection endpoint which in turn could take the contents of the error and add it to the Rails log or whatever log.
This old gem does that. I realize this questions is 8 years old.

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