【发布时间】:2014-01-17 22:56:49
【问题描述】:
所以我不应该在这个输入字段上使用表单标签(导致每个后端人员的错误)
选择/活动激活提交时,我将如何允许用户使用Enter密钥?
用户可以手动点击添加组提交按钮,也可以tab点击,但不能直接进入点击:(
表格
<input type="text"
id="group-code" value="Type your Group Code Here" name="Type your Group Code Here"
onblur="if (this.value == '') {this.value = 'Type your Group Code Here';}"
onfocus="if (this.value == 'Type your Group Code Here') {this.value = '';}"
autocomplete="off"/>
<button class="btn" id="btn_join_group">add group</button>
<!--<input type="submit" id="btn_join_group" form="group-code" value="add group"/>-->
jQuery
$('#btn_join_group').unbind('click').bind("click", function(event) {
var newGroup = $('#group-code').val();
// Send Group code to server
WHOAT.networking.getToServerWithAjax('/groups/join', newGroup, function (response) {
var res = JSON.parse(response);
if (res.result === 'success') {
notification.setStatusAndFadeStatus(response);
} else if (res.result === 'error') {
notification.setStatusAndFadeStatus(response);
}
});
});
【问题讨论】:
标签: javascript jquery forms input