Click here to Skip to main content
15,042,681 members

Comments by Brian A Stephens (Top 75 by date)

Brian A Stephens 11-Apr-15 10:33am View
@prasannakumarmp: That's all the code you need. Just wrap it in a $(document).ready(), though, to be sure. I'll update the solution.
Brian A Stephens 18-Dec-14 15:27pm View
It still allows for one-digit and three-digit years, as the OP requested. Not sure what dates he's expecting, but (\d{2}){1,2} might be better.
Brian A Stephens 18-Dec-14 15:00pm View
Reason for my vote of 5 \n This provides a good background for the purpose and goals of Angular. Nice job!
Brian A Stephens 27-Aug-14 13:48pm View
jQuery simplifies the process of getting code to fire after the DOM is fully loaded: use $(document).ready()
Brian A Stephens 26-Aug-14 8:51am View
Sorry, I forgot about that stipulation. I've updated it now.
Brian A Stephens 25-Aug-14 13:32pm View
Could you post more code? Post the relevant HTML and HTTPGET request. Thanks.
Brian A Stephens 12-Aug-14 10:35am View
So all you are really doing is declaring that you need a regular expression. Not a very specific statement, and certainly not a question.
Brian A Stephens 2-Jul-14 9:40am View
Reason for my vote of 5 \n good explanation
Brian A Stephens 30-Jun-14 13:20pm View
Can you show us the relevant HTML? What error/result did you get?
Brian A Stephens 26-Jun-14 8:42am View
Reason for my vote of 4 \n this could be very useful. thanks.
Brian A Stephens 25-Jun-14 14:29pm View
Reason for my vote of 5 \n sleek styling!
Brian A Stephens 25-Jun-14 14:25pm View
Reason for my vote of 5 \n very good
Brian A Stephens 24-Jun-14 8:59am View
yes, or .css('max-height', '100%');
Brian A Stephens 18-Jun-14 16:21pm View
It looks like Torakami was trying to use the deprecated toggle method (removed in jQuery 1.9) that allowed for alternating event handlers on an element ( So in this case, he wasn't trying to hide and show the elements.
Brian A Stephens 16-Jun-14 15:28pm View
This also corrects the issue of allowing underscores, which presumably he did not want. Now, if he truly wants to allow "spaces" rather than any whitespace, that's another change.
Brian A Stephens 11-Jun-14 8:22am View
Reason for my vote of 5 \n good to know
Brian A Stephens 10-Jun-14 15:36pm View
You don't have any #ad_whatever DIVs in your HTML. Where are they?
Brian A Stephens 6-Jun-14 13:37pm View
I would also caution against your use of $(this).attr('class'), since it will return ALL classes of the element. You may very well add another class for styling purposes that will remain in both the "like" and "unlike" states. It's more precise to use $(this).hasClass('like').
Brian A Stephens 16-Apr-14 15:33pm View
Your handler will be triggered by ANY element with the class "chk-jobOffer" being clicked. Then your conditional will check if the FIRST such element is checked, which is not necessarily what you want. You are assuming there's only one matching element.
Brian A Stephens 25-Feb-14 14:09pm View
I realized that I misunderstood what the navigation was controlling. Try my update for a complete solution.
Brian A Stephens 31-Jan-14 9:20am View
I see that you may have two possible problems. You need to define the regex using a verbatim string literal, so the backslashes aren't interpreted in the string itself: string pattern = @"(\$\d+(,\d{3})*|\d+(,\d{3})*\$)". Secondly, if you are using Regex.Matches, it should return ALL matches, not just the first.
Brian A Stephens 8-Jan-14 12:55pm View
I added a jsFiddle to show the difference with the new CSS. Try it out.
Brian A Stephens 30-Dec-13 9:40am View
The code tells it all! You are trying to validate each character on its own, but your requirements make this impossible ("dot should come in the middle of the string and only once"). Because of the dot validation, you must consider the entire string, not just one letter. You will need to change this line:
var str = $('#txtFileName').val();

But you still have the problem that keypress happens BEFORE the new text becomes part of the input field value. You need to validate the text that includes the new key. That can only happen in keyup, but that's too late to prevent the key's action.

You need to either validate the entire filename on submit rather than entry, or keep track of a "previous" value for the input so you can revert it back in a keyup handler if the new value doesn't validate.
Brian A Stephens 20-Dec-13 8:21am View
OK, so my regex is what you need. It allows for the possibility of one dot followed by more letters or numbers. I'm not sure why you're not getting it to work. Can you post your code? If you are using
new RegExp(" ... ")
syntax, be sure you escape the escape character (double backslash) because it's also an escape character within quotes.
Brian A Stephens 11-Dec-13 16:09pm View
Reason for my vote of 4 \n good, practical code
Brian A Stephens 20-Nov-13 14:58pm View
Agree completely with SA. And what are those <left> tags?
Brian A Stephens 28-Oct-13 13:42pm View
Reason for my vote of 5 \n useful information
Brian A Stephens 28-Oct-13 13:23pm View
Reason for my vote of 5 \n Great idea. And this is all front-end optimization, based on what you can see as a user. Just think of the room for improvement having access to all the code.
Brian A Stephens 28-Oct-13 13:18pm View
Wow, this is unclear. It would help to see what "some code" means. And what do you mean by "try to remove the code for the watermark"?
Brian A Stephens 24-Oct-13 10:17am View
Realize, though, that "\w" matches all alphanumerics and underscore. If he really means "alpha", you have to use "[A-Za-z]".
Brian A Stephens 24-Oct-13 9:59am View
Also, the expression allows "100.%", which is strange. The "0{0,2}" should be changed to "0[1,2}" to force at least one digit after the decimal.
Brian A Stephens 21-Oct-13 11:21am View
Reason for my vote of 5 \n good explanation.

Note: you need to clean up some errant text in the line with "if Name field length >=5 then flag ...". You must have pasted it in by mistake.
Brian A Stephens 17-Oct-13 8:16am View
Reason for my vote of 5 \n good advice, and written clearly
Brian A Stephens 11-Oct-13 15:59pm View
You tagged this question with HTML5 only, not Javascript. With HTML5 only, the closest you'll get is the new pattern attribute of input tags. It will prevent any characters that don't match the specified regex.

But if you want to allow the copy/paste, but clean it for the user, you'll need Javascript or server-side code. Write a JS function that utilizes regex to replace the invalid characters, bound to the onkeypress event.
Brian A Stephens 11-Oct-13 9:00am View
Reason for my vote of 5 \n very useful
Brian A Stephens 1-Oct-13 11:03am View
Or simplify the function to one line:
$("#spnChk").toggleClass("disabled checked");

You just have to add the "disabled" class to spnChk so it defaults correctly.
Brian A Stephens 1-Oct-13 10:00am View
Now that makes sense!
Brian A Stephens 27-Sep-13 9:26am View
Reason for my vote of 5 \n handy tip
Brian A Stephens 27-Sep-13 9:18am View
This regex allows any number of digits. He said it should be 10 max. There should obviously be a minimum too, but that was not stated.
Brian A Stephens 27-Sep-13 9:13am View
This has nothing to do with jQuery
Brian A Stephens 25-Sep-13 12:36pm View
After I posted my answer and saw yours, I realized that he must be looking for an element with value="art6" INSIDE an anchor because "value" is not a valid attribute of an anchor tag.
Brian A Stephens 24-Sep-13 10:52am View
Be sure you specify the RegexOptions.Multiline option to change the meaning of ^ and $ to be per line.
Brian A Stephens 24-Sep-13 9:00am View
What result are you getting? The caret ^ ensures that the line has to start with the matching text, so it should match only one line from your sample.
Brian A Stephens 20-Sep-13 10:10am View
Your regex allows numbers 11-19 also, which shouldn't be included.
Brian A Stephens 19-Sep-13 12:30pm View
Reason for my vote of 5 \n great tips! this all makes sense.
Brian A Stephens 29-Jul-13 11:00am View
Reason for my vote of 3 \n good tip, but all it did was document the existing jQueryUI call
Brian A Stephens 29-Jul-13 10:52am View
Reason for my vote of 5 \n good tip
Brian A Stephens 22-Jul-13 15:32pm View
Reason for my vote of 5 \n short and to the point
Brian A Stephens 9-Jul-13 11:01am View
To match a dash (hyphen) in a character class, the dash needs to be either first or last, or be escaped. The syntax you have given may work inadvertently, but is not correct because of the space at the end.
Brian A Stephens 1-Jul-13 8:33am View
Reason for my vote of 5 \n good intro
Brian A Stephens 28-Jun-13 13:38pm View
Reason for my vote of 3 \n Good try, but it doesn't work well. I tried 2013-05-31 (with today's date being 2013-06-28), and the output was 1 month and -2 days. While that's true in a very awkward way, it's not the intended output. Also, why do you initialize the "Days" and "Months" variables but never use the initial values?

I think this is a valuable algorithm to work out, so thank you for the effort and hopefully you can work out these bugs.
Brian A Stephens 27-Jun-13 12:38pm View
Reason for my vote of 5 \n clean look, achieved with small footprint
Brian A Stephens 13-Jun-13 15:25pm View
Please also label your question correctly. "Browser compatibility issue" is very vague and there are at least 4 extra tags that aren't relevant (this has nothing to do with .NET or C#).
Brian A Stephens 13-Jun-13 11:17am View
It's difficult to determine exactly how this code will be used. Can you provide the accompanying HTML, or even better, a jsFiddle example? Also, it looks like you have a mistake in the CSS: there are two definitions for ".tip". Did you mean the second one to be ".tipTop"?
Brian A Stephens 30-May-13 15:26pm View
So my solution above should do what you want. If so, please "accept" it as the answer; if not, then clarify what you want different. Thanks.
Brian A Stephens 29-May-13 10:19am View
Reason for my vote of 5 \n good trick
Brian A Stephens 20-May-13 9:59am View
It's very strange that all you are validating about a phone number is its length. Why are you not using a regex to ensure that it's all numbers, dashes, etc., of the correct format?
Brian A Stephens 13-May-13 15:42pm View
You should probably provide a jsFiddle. What you have posted here includes a 1px font size on all the menu links, so the menu is not readable. It's also unclear how you WANT the menu to look when there isn't enough room for all the items on one line. There are many ways to style a menu for such circumstances.
Brian A Stephens 8-May-13 9:15am View
What does this have to do with or an IFrame?
Brian A Stephens 8-May-13 8:06am View
You've gotta provide more information than this! Your code implies that it's more than just a click event that's broken, since you have an alert that presumably isn't firing either (or does the first alert work?). Check the generated HTML page to ensure that the reference to jQuery is correct. Tell us if there's any error from the console, etc.
Brian A Stephens 1-May-13 9:26am View
I was wondering the same thing. Got my downvote.
Brian A Stephens 1-May-13 8:41am View
I tried this code in IE, and it works. Can you post the code to jsFiddle, as it was rendered by MVC? I didn't use MVC; I entered the <label> and <input> tags manually. Also, what version of IE were you trying?
Brian A Stephens 29-Apr-13 16:04pm View
Please post any JS related to the above code and reveal the html SOURCE, rather than rendered. It looks like you have a clickimagechange() function that we need to see. From piecing apart the HTML in the page source of your post, it looks like your LI and UL tags are all scrambled. I would rather see just the relevant code here than go out to the full external site. Thanks.
Brian A Stephens 24-Apr-13 8:31am View
[In reply to mvamsianil] Yes, she is using jQuery (notice the jQuery selectors in the code). jQuery code should generally be inside a document.ready callback (I'm not sure whether this is), but I don't understand your comment. The code that DEFINES the function will be run only once whether it's in a document.ready or not - it's just the timing of the definition that would change. The click event should call the function every time.

Have you debugged in the browser to step through and see what's happening?
Brian A Stephens 24-Apr-13 8:23am View
The $ in the selector indicates that the id attribute should END with the given value, rather than being equal. It's one approach when using ASP.NET web forms, which generate their own IDs on the fly.
Brian A Stephens 23-Apr-13 15:54pm View
Please clarify whether you are using the jQuery UI tab control - that's my guess. It's hard to determine what's wrong with your code without seeing it. Can you create a jsFiddle?
Brian A Stephens 23-Apr-13 8:05am View
The proper syntax for a relative change is += or -= not just the "+25%" you have above. The "+25%" would probably be interpreted by most browsers the same as "25%" - just an indication that it's a positive number.
Brian A Stephens 22-Apr-13 10:39am View
This code returns the height of ONE item (the largest item) within the div, not the cumulative total height. The question is about the total height.
Brian A Stephens 22-Apr-13 8:50am View
It's unclear what you are trying to do with this, especially because your code isn't valid. What are the "removed" CSS styles supposed to be? I changed most of them to "position" and got an effect where each time you click, div1 slides further to the left and div2 slides further to the right. What else do you want? What's the point of checking whether the container is visible, since it will always be?
Brian A Stephens 18-Apr-13 9:15am View
Shouldn't that be "border-left-color" instead of "borderLeftColor" in the css() call?
Brian A Stephens 18-Apr-13 8:47am View
You are right, sorry. I changed my vote. Your answer is valid and applies to some alternate situations too. When I first read your answer, I misunderstood what you were saying.
Brian A Stephens 17-Apr-13 10:51am View
I added working code to the solution, with a jsFiddle example.
Brian A Stephens 9-Apr-13 9:10am View
When you inspect the element after the page loads, do the dynamic radio buttons look right? What if you copy the generated HTML and paste it into the document, temporarily bypassing the dynamic generation: does it work? You should just rule out subtle syntax differences before assuming it's a problem with being dynamically generated. For instance, your dynamic tags have the XHTML-style end slash, but the static ones don't.
Brian A Stephens 9-Apr-13 8:02am View
So it looks like you are using the jQuery Validation Plugin. But what is your question? Have you tried this code and are getting an error?
Brian A Stephens 8-Apr-13 21:31pm View
Ah, yes: negative lookahead; that's the elegant way to do it. However, the regex you provided doesn't match lines that fail the requirement of a pipe in the 11th position. With a slight modification, it will match those too: ^(?!\d{10}\|).*$