How can I disable an input-field with jQuery using GM if the url contains text?
I tried
$(document).ready( function() {
if($("url:contains('text')")){
$(".input[id=field-owner]:disabled");
}
else {
$(".input[id=field-owner]:enabled");
}
});
I don't know what I did wrong. And I also don't know whether url:code is a regular expression to use.
Update
Hi again, thanks for your time putting in this. I guess it's easier to ask/answer how to call an alert when the url contains e.g. "newthread".
So, we have got a url(e.g.): http://forum.jswelt.de/newthread.php?do=newthread&f=1 , and an input-field with id="subject" and a label for "subject". If the url contains "newthread" the input-and label-element should be hidden. Following code works, but not for me. The console says nothing and won't alert though.
var url = window.location.href
url = "http://forum.jswelt.de/newthread.php?do=newthread&f=1";
var pos = url.search(/newthread/);
if(pos >= 0)
alert("tadaa");
else
alert("mist");
:(
Thank you to all helping me.
Edit inserts the final solution
if (location.href.indexOf("text") != -1) {
$('#fieldname').attr("disabled", true);