Is there any existing Python library that can validate data in Excel format? Or what kind of keyword should I use to search such an open source project? Thanks.
I'm taking user input from System.in using a java.util.Scanner. I need to validate the input for things like:
It must be a non-negative number
It must be an alphabetical letter
...etc
What's the best way to do this?
May websites, including professional ones usually have a "W3C Markup Validator" and "W3C CSS Validator." Why do you put them there? Is it just pride or is it justified? If it is more than pride, what justifies them?
How do I use jQuery validator to add/remove a classname (e.g. validate) on the form element's parent <li> so I can style everything related to that element by only setting the one classname?
The markup is
<li class="validate">
<label for="product">Product of interest <abbr title="Required field">*</abbr></label>
<input id="product" type="text" name="product" value="" placeholder="e.g. school bench" class="required" minlength="2">
<!-- Hidden by CSS unless parent has 'validate' class -->
<label for="product" class="description">Please name a product.</label>
</li>
and the default jQuery is
$("#commentForm").validate();
I have an input field in a form. Upon pushing submit, I want to validate to make sure the user entered non-latin characters only, so any foreign language characters, like Chinese among many others. Or at the very least test to make sure it does not contain any latin characters.
Could I use a regular expression for this? What would be the best approach for this?
I am validating in both javaScript and in PHP. What solutions can I use to check for foreign characters in the input field in both programming languages?
Ok steps to reproduce this:
prompt> rails test_app
prompt> cd test_app
prompt> script/generate model event_service published:boolean
then go into the migration and add not null and default published to false:
class CreateEventServices < ActiveRecord::Migration
def self.up
create_table :event_services do |t|
t.boolean :published, :null => false, :default => false
t.timestamps
end
end
def self.down
drop_table :event_services
end
end
now migrate your changes and run your tests:
prompt>rake db:migrate
prompt>rake
You should get no errors at this time. Now edit the model so that you validate_presence_of published:
class EventService < ActiveRecord::Base
validates_presence_of :published
end
Now edit the unit test event_service_test.rb:
require 'test_helper'
class EventServiceTest < ActiveSupport::TestCase
test "the truth" do
e = EventServer.new
e.published = false
assert e.valid?
end
end
and run rake:
prompt>rake
You will get an error in the test. Now set e.published to true and rerun the test. IT WORKS! I think this probably has something to do with the field being boolean but I can't figure it out. Is this a bug in rails? or am I doing something wrong?
I have built a custom form for creating a joining model on a has_many :through relationship. The models look roughly like this:
class Team
has_many :team_members
has_many :members, :through => :team_members
end
class Member
has_many :team_members
has_many :teams, :through => :team_members
end
class TeamMember
belongs_to :team
belongs_to :member
# and this model has some validations too
end
The form I have built is for selecting which members should be in a team. I won't paste the form, but it uses the form_tag method and basically sends an array of hashes which contain a member_id and a squad_number. I then update the database with an action that looks roughly like this (simplified a bit, but you get the jist):
@team.transaction do
@team.team_members = params[:team_members].collect{|tm| @team.team_members.new(tm)}
if @team.save
redirect_to ...
else
render :action => :members
end
end
Everything works great but I am validating the squad_number for uniqueness and numerically. So, when any of those validations fail, how do I get access to them in my view, and how do I ascertain which of the many members it has failed on?
What is the best way for converting phone numbers into international format (E.164) using Java?
Given a 'phone number' and a country id (let's say an ISO country code), I would like to convert it into a standard E.164 international format phone number.
I am sure I can do it by hand quite easily - but I would not be sure it would work correctly in all situations.
Which Java framework/library/utility would you recommend to accomplish this?
P.S. The 'phone number' could be anything identifiable by the general public - such as
* (510) 786-0404
* 1-800-GOT-MILK
* +44-(0)800-7310658
that last one is my favourite - it is how some people write their number in the UK and means that you should either use the +44 or you should use the 0.
The E.164 format number should be all numeric, and use the full international country code (e.g.+44)
heres my code -
function Validate_URL(url) {
var iurl = url.value;
var v = new RegExp();
v.compile("/^(((ht|f){1}(tp:[/][/]){1})|((www.){1}))[-a-zA-Z0-9@:%_+.~#?&//=]+$/;");
if (!v.test(iurl.value)) {
url.style.backgroundColor = 'yellow';
}
return true;
}
no matter what i put in url, say http://www.abc.com/newpage.html, it returns false. how come?
I have a form that has several conditional form elements. For example If x is selected in dropdown a, show/hide textfield a etc..
Is there a plugin for it or do I have to write those conditions manually?
Thanks for your help!
Hi,
Why does the Javascript function call isNaN(123.) return false? Is this a universally acceptable number or will it cause errors downstream?
I'm validating whether a value is a valid decimal using isNaN along with split. Are there cross-browser issues with isNaN? Should I use a bespoke implementation?
Thanks.
I have a projects resource that has many tasks. I want to ensure that every task has a project_id by adding validates_presence_of :project_id to the tasks model.
However, when creating a new project with tasks, the project_id won't be available until the record saves, therefore I can't use validates_presence_of :project_id.
So my question is, how do I validate presence of project_id in the task model? I want to ensure every task has a parent.
...
class Project < ActiveRecord::Base
has_many :tasks, :dependent => :destroy
accepts_nested_attributes_for :tasks, :allow_destroy => true
...
class Task < ActiveRecord::Base
belongs_to :project
validates_presence_of :project_id
For example, you send an unsubscribe message to a legitimate company or a spam, they reply that they will remove you and it may take up to 72 hours to take effect. I find it hard to believe anything that simple could take more than 3/4 of a second to take effect system wide.
Another example would be when you call the visa activation line, there is a "delay" of several minutes while they try to sell you some kind of insurance. Usually just as you get the point across that you don't want it they will tell you your card has been activated and let you go.
Are these delays real?
I have asp:RegularExpressionValidator with ValidationExpression="\d+{1,4}(?:[.,]\d{1,4})?" but it doesn't' work, parser throws ArgumentException:
parsing "\d+{1,4}(?:[.,]\d{1,4})?" -
Nested quantifier {.
Where is my mistake? I want to allow strings like xxxx,xxxx - from 1 to 4 digits and decimal digits are not required, e.g.: 1000, 99,99, 0,2498, etc.
I am a beginner in jQuery and I was wondering how to validate the form before submission specifically for check boxes.
I am creating a simple check list form where my user would tick a check box if he finished that step. What I am planning to do is that, the script would prevent the form submission if there is an "unticked" checkbox and highlight it with a color.
Here's my code :
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>checkbox</title>
<style>
.error {
background-color:#F00;
}
.valid {
background-color:#0F0;
}
</style>
<script type="application/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"> </script>
<script type="application/javascript">
function validateAll() {
$(".tick").change(function(){
if ($('.tick:checked').length == $('.tick').length) {
$('#container').removeClass();
$('#container').addClass('error');
} else {
$('#container').removeClass();
$('#container').addClass('valid');
}
});
}
</script>
</head>
<body>
<div id="container"><input class="tick" id="option1" type="checkbox"></div>
<div id="container"><input class="tick" id="option1" type="checkbox"></div>
<input id="button" type="button" onClick="validateAll();" value="check">
</body>
</html>
So what I am trying to do here is when the user clicks the button, the script will highlight all the unchecked check box with red and highlight all checked with green.
However, my script is not functioning. What is wrong with my script? Any suggestions on a more efficient way to do this?
If I have a pointer, like char* foo, is there any way to determine if foo points to a valid location in memory? (So, foo is not NULL, and delete has not yet been called on it.)
So I need to get value false or true if string contains not only letters of all european and east alphabets and " "(space) and "-" minus. How to do such thing with some $a string?
My web page content is populated by a plain text that is retrieved from a CDATA format - plain text data.
This is the site http://checksite.apsx to get information.
For more information, visit http://moresites.com/FAQ/index.html or search the site.
Now, my goal is to convert this plain text to a valid hyperlinks.
I've used a javascript code that does the conversion - /((http|https|ftp):\/\/[^ ]+)/g;
, but sometimes if there are multiple words, it captures an invalid URL.
My question: Is there a way to strictly capture any string that starts with "http" AND ends with ".html" or "aspx" will be converted into a valid hyperlink?
it should look like this -
This is the site http://checksite.apsx to get information.
For more information, visit http://moresites.com/FAQ/index.html or search the site.
Recently a lot of browser-based training sites have been spawned. These include tryruby.org, codeacademy.org, codeschool.org and the Udacity site uses something seemingly similar. They allow the user to type code in say Ruby or Python, this is then sent to the server and the output posted back to the browser.
Are there libraries available for in-browser code validation?
How would you approach this?
Suggestions?
Hi! I'm doing my VERY first project using python/django/eclipse/pydev following this guide
http://docs.djangoproject.com/en/dev/intro/tutorial01/
My only addition is the use of Eclipse/pydev.
I'm getting many errors related to "Unresolved imports". I can remove the errors using "remove error markers" and my site runs perfect (I can browse it) but I want to get rid definitively of this problem since errors appear again after I removed them.
Any ideas?
In many django projects, in the docs directory I can see *.rst files :
What is the best way to browse them (without using a text editor of course) ?
Is that possible to generate HTML ?
Alias /media/ /home/matt/repos/hello/media
<Directory /home/matt/repos/hello/media>
Options -Indexes
Order deny,allow
Allow from all
</Directory>
WSGIScriptAlias / /home/matt/repos/hello/wsgi/django.wsgi
/media is my directory. When I go to mydomain.com/media/, it says 403 Forbidden. And, the rest of my site doesn't work because all static files are 404s. Why?
Edit: hello is my project folder
I'm developing a website using the Django framework, and I need to retrieve Jabber (okay, Google Talk) statuses for a user. Most of the Jabber python libraries seem like an incredible amount of overkill (and overhead) for a simple task. Is there any simple way to do this?
I know very little about XMPP/Jabber, though of course I'm willing to learn. Do you need to be an authenticated and "friended" user to retrieve another user's status?
Is there a wysiwyg editor for the web, like tinymce or wmd, which can produce restructured text? I'm looking for something which can be integrated with django.
I would like to use rst instead of markdown because I need to convert the content entered to pdf and do some layout specific things which make rst look like a better choice.