forms - jQuery: textfield name selector -
i have form:
<form id="userform" action="xpto"> <input type="text" name="form[data_nascimento_beneficiario_1]" value /> <input type="submit" value="continuar" /> </form> now on script file try lenght of field validation:
$("#userform").submit(function (e) { alert($("input[name="form[data_nascimento_beneficiario_1]"]).length()); }); but "typeerror: cannot call method 'length' of null",
i guess problem on name have "form[]", nothing can change :(
can me please?
regards all.
a few issues there:
your code quoted has syntax error , wouldn't give error you've said, you've ended javascript string after word
name.when attribute value you're testing contains letters a-z, it's best put in quotes.
length"th" @ end, not "ht"...and in jquery it's property, not method, don't want
()after itthe name you're using in selector (
data_nascimento_baneficiario_1) doesn't match name in form (data_nascimento_beneficiario_1), note "a" @ beginning of "baneficiario" in selector.
all together: live example | source
alert($('input[name="form[data_nascimento_beneficiario_1]"]').length); (there, i've used ' put quotes around selector string , " put quotes around attribute value. other way around works.)
Comments
Post a Comment