JQuery验证仅适用于提交表单中的第一个元素,验证不会检查第二个元素.需要找出缺少的东西.交换text1和date2的输入,验证仍适用于第一个.
<!DOCTYPE HTML>
<html lang="en-US">
<head><title>
</title>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.5.1.min.js'></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.js"></script>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.5.5/jquery.validate.min.js"></script>
<script type="text/javascript" src="http://jquery-multifile-plugin.googlecode.com/svn-history/r16/trunk/jquery.MetaData.js"></script>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/themes/base/jquery-ui.css"/>
<script type="text/javascript">
$(document).ready(function () {
$("#form1").validate();
$(".date").datepicker({
changeYear: true,
dateFormat: 'dd/mm/yy',
minDate: new Date('1990/01/01'),
maxDate: '30Y'
});
});
function test() {
alert(document.getElementById("datetext").getAttribute("must"));
}
</script>
</head>
<body>
<form method="post" action="WebForm1.aspx" id="form1">
Text:<font color="red">* </font><input id="Text1" class="lvl {required:true,messages:{required:'blank not allowed.'}}" /><br />
Select Date2:<font color="red">* </font><input id="date2" class="date {required:true,messages:{required:'Required:Need to enter 2 date.'}}" readonly="true" /><br />
<input type="submit" value="Submit"/> …
Run Code Online (Sandbox Code Playgroud) 例如,
Date d = "2012-08-20T15:00:00-07:00";
Run Code Online (Sandbox Code Playgroud)
d
这是一个UTC时间,时间偏移= 07:00
.它仍然需要Z
这样2012-08-20T15:00:00-07:00Z
吗?它是否正确?
如果我使用此字符串Z
并使用Date.parse()
JavaScript中的方法来设置它,则会引发错误.不确定有什么问题!
我正在为AngularJS指令编写测试,该指令<textarea>
在按下某些键时触发事件.根据我的手动测试,一切正常.我想要做得很好,也有一个完整的单元测试套件,但是我遇到了一个我自己无法解决的问题:
我想在我的测试中发送一个特定keyCode
的triggerHandler()
调用,但我找不到一种方法来指定实际工作的密钥.我知道有关构建和发送具有特定数据的事件的主题的许多问题和答案,但它们都不适用于我的设置:
var event = document.createEvent("Events");
event.initEvent("keydown", true, true);
event.keyCode = 40; // in debugging the test in Firefox, the event object can be seen to have no "keyCode" property even after this step
textarea.triggerHandler(event); // my keydown handler does not fire
Run Code Online (Sandbox Code Playgroud)
奇怪的是,我可以在Chrome中键入控制台中的前3行,并看到正在创建事件时将keyCode
属性设置为40.所以看起来应该可以正常工作.
此外,当我像这样调用最后一行时,textarea.triggerHandler("keydown");
它工作,并触发事件处理程序.然而,没有keyCode
合作,所以这是毫无意义的.
我怀疑它可能与针对DOM运行的测试的性质有关,该DOM与浏览器中运行的常规页面不同.但我无法弄清楚!
有没有办法以编程方式(通过ioctl()等)或通过读取/ sys,/ proc或/ dev中的文件来检查屏幕是否已被Linux控制台屏幕保护程序消隐?
谢谢和最好的问候,
冈特
Ruby 1.9版的csv
header %w[first second third]
data = ["column one",,"column three"]
CSV.open("myfile.csv","w") do |csv|
csv << header
csv << data
end
Run Code Online (Sandbox Code Playgroud)
在这个简单的例子中,数据数组中的空中间会导致错误,但如果使用空引号"",则不会出现错误并创建CSV文件.但是我想让CSV文件没有空引用的segement.
具体来说,如何生成没有引号的CSV文件的空白部分?数据可以是空变量,但仍应编写逗号.
我的应用程序上有一个WebView,我无法更改html文件("target = _blank"链接类型).但是页面上的一些链接使我的应用程序在系统浏览器上打开它们.我怎么能不允许这个动作?
谢谢.
我正在尝试用Mocha编写的测试来运行Karma,它们有点工作,但我不能使用done()方法来实现异步测试,这实际上使得这些工具对我来说毫无用处.我错过了什么?
karma.conf.js
module.exports = function(config) {
config.set({
basePath: '../..',
frameworks: ['mocha', 'requirejs', 'qunit'],
client: {
mocha: {
ui: 'bdd'
}
},
files: [
{pattern: 'libs/**/*.js', included: false},
{pattern: 'src/**/*.js', included: false},
{pattern: 'tests/mocha/mocha.js', included: false},
{pattern: 'tests/should/should.js', included: false},
{pattern: 'tests/**/*Spec.js', included: false},
'tests/karma/test-main.js'
],
exclude: [
'src/main.js'
],
// test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: ['progress', 'dots'],
port: 9876,
colors: true,
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO …
Run Code Online (Sandbox Code Playgroud) 在我的组件的render方法中,我将作为父级的antd Modal组件和作为子级的antd Form组件:
render() {
const myForm = Form.create()(AddNewItemForm);
...
return (
...
<Modal
title="Create new item"
visible={this.state.visible}
onOk={this.handleOk}
onCancel={this.handleCancel}
wrapClassName="vertical-center-modal"
okText="Save new item"
width="600"
>
<myForm />
</Modal>
...
Run Code Online (Sandbox Code Playgroud)
如何通过单击"模态保存"按钮提交表单?
为什么在使用类方法作为回调时以及使用"普通函数" 时Promise.then
传递执行上下文?undefined
window
类方法是否与其拥有的对象/类分离?为什么undefined
而不是window
?
function normal() {
console.log('normal function', this);
}
const arrow = () => {
console.log('arrow function', this);
}
function strictFunction() {
'use strict';
console.log('strict function', this);
}
class Foo {
test() {
this.method(); // Foo
Promise.resolve().then(() => console.log('inline arrow function', this)); // Foo
Promise.resolve().then(normal); // window
Promise.resolve().then(arrow); // window
Promise.resolve().then(strictFunction); // undefined
Promise.resolve().then(this.method); // undefined <-- why?
}
method() {
console.log('method', this);
}
}
const F = new Foo();
F.test(); …
Run Code Online (Sandbox Code Playgroud) 我希望有人能告诉我为什么下面的代码每次都创建一个空的pdf文件?
我正在尝试编译,填充和运行xmldatasource
JasperReports 4.0.2附带的示例项目.虽然我正在尝试以编程方式进行,因为我想在我自己的软件中使用类似的(非基于蚂蚁的)编译方法.Jasper附带的同一个项目使用ant脚本来创建报告,它可以工作.所以我知道JRXML文件没有问题.但是,我似乎无法正确填写数据报告.
当我调试Jasper引擎源以查看我的XML源文档是否正确加载时,我看到它PARAMETER_XML_DOCUMENT
具有值
[#document:null]
您是否认为这意味着XML源文件未被正确读取?
代码编译并运行没有错误,并生成所有相关文件(.jasper,.jrprint和.pdf),但由于某种原因,渲染的PDF文档似乎每次只有一个空白页.
任何帮助是极大的赞赏...
public static void main(String[] args) {
Map map = new RenderReportBean().execute("northwind", "OrdersReport");
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public Map execute(String sourceFileId, String templateId, Integer[] formats) {
Map params = new HashMap();
Document document;
Map<Integer, Boolean> renderedSuccessList = new HashMap<Integer, Boolean>();
try {
document = JRXmlUtils.parse(JRLoader.getLocationInputStream(sourceFileId + ".xml"));
params.put(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT, document);
params.put(JRXPathQueryExecuterFactory.XML_DATE_PATTERN, "yyyy-MM-dd");
params.put(JRXPathQueryExecuterFactory.XML_NUMBER_PATTERN, "#,##0.##");
params.put(JRXPathQueryExecuterFactory.XML_LOCALE, Locale.ENGLISH);
params.put(JRParameter.REPORT_LOCALE, Locale.US);
JasperCompileManager.compileReportToFile(templateId + ".jrxml", templateId + ".jasper");
JasperFillManager.fillReportToFile(templateId + ".jasper", params);
JasperExportManager.exportReportToPdfFile(templateId …
Run Code Online (Sandbox Code Playgroud) javascript ×5
karma-runner ×2
unit-testing ×2
angularjs ×1
antd ×1
c# ×1
compilation ×1
console ×1
csv ×1
date ×1
ecmascript-6 ×1
es6-promise ×1
input ×1
jasmine ×1
java ×1
jquery ×1
karma-mocha ×1
linux ×1
mocha.js ×1
parsing ×1
pdf ×1
promise ×1
reactjs ×1
ruby ×1
ruby-1.9 ×1
screensaver ×1
target ×1
utc ×1
validation ×1
webview ×1