I'm using the jQuery Clean Calendar Plugin, and it's working well. However, in my jQuery code, I want to check whether any '/' is present in textbox.val(). Then I want to do some operations. How do I check if the value contains '/' in it?
-
2I can't tell you how much this question depresses me.annakata– annakata2009-06-15 11:45:50 +00:00Commented Jun 15, 2009 at 11:45
-
7Annakata, that's not very constructive, is it? He's clearly just getting familiar with jQuery, and likely programming as a whole. I mean no disrespect, but lets encourage those who are new to the field. We were once where they are too.Sampson– Sampson2009-06-15 11:47:51 +00:00Commented Jun 15, 2009 at 11:47
Add a comment
|
2 Answers
Just to suggest a slightly more concise way to do it, using ternary and match() instead:
$( "#id").attr( "some_attr").match('/') ? alert('got a forward slash') : alert('no forward slash');
2 Comments
Sampson
I love the ternary operator, but I'm thinking it may confuse the original poster. He seems relatively new to programming, and the if/then structure might make more sense than the () ? : ; structure.
karim79
@Jonathan - I totally agree with you. I just felt like suggesting it as no-one else had, and to introduce a bit of variety.