我有一个输入字段,我需要确保输入字段只有字母表中的字符,而不是:
我想使用if else语句来做这件事。到目前为止,代码是:
HTML:
case hsh['property']
when Hash
HashWithIndifferentAccess.new(
hsh['property']['name'] => hsh['property']['value']
)
when Array
hsh['property'].each_with_object(HashWithIndifferentAccess.new) do |kv_pair, scan|
scan[kv_pair['name']] = kv_pair['value']
end
else
# Uh-oh, you've got to handle this case of something random.
end
JavaScript是:
<form id="myform" onsubmit="return check();" >
<input class="input" type="text" name="firstname">