jquery – Formfill in Javascript not working?
jquery – Formfill in Javascript not working?
I think the error is with this line
if (!$(#tagnames).val().length)
length will return a number and check that against number.
Something like
if ($(#tagnames).val().length > 0)
I dont think there is a need to place document ready inside the if statement. Isnt this better.
$(function() {
var tagMatch;
if (tagMatch = window.location.href.match(//questions/ask?tags=([^&]+)/))
{
if ($(#tagnames).val().length > 0)
{
$(#tagnames).val(unescape(match[1].replace(/+/g, ));
}
}
});
Without looking too much into how the string matching works…
You seem to be defining and setting a variable called tagMatch
, but then youre using a variable called match
to set the value.
Is that the problem?
Update: Apologies – your regex is correct – I misread the intention 🙂