Jump to content

callumacrae

Members
  • Posts

    89
  • Joined

  • Last visited

Posts posted by callumacrae

  1. If you've written your login code correct, you should have a sessions table; just add a column to show when the user was last active. If you haven't got a sessions table, you are not of a level of PHP where you should be writing a login system. They're one of the trickiest things to write, and if you mess them up and get hacked, you will annoy a lot of people.

  2. Yeah, you can modify document.title to change the title of the page:

    document.title = prompt('Modify the title', document.title);

    However, you shouldn't use the prompt function. It's ugly and invasive, and your users will hate you. You should use an input box on your page instead.

  3. Regular expressions have the following syntax:

    /expression/flags

    The two forwards slashes (/) are what makes it a regular expression, just like strings have quotes around them. The expression is the regular expression itself, and the flags are stuff like telling the regular expression to be global ("g" is the modifier, not "/g"). I would recommend disregarding the w3schools regex ref you linked to, it isn't very good.

    • Like 1
  4. Also important, you never call the validate function. It has to be called from within reply_click. As it is, all that code does nothing. I don't see why you need the internal function anyway, if that's where most of the code is going to be. BTW, your users are going to hate you for making them sit through a potentially long string of alerts. Changing the innerHTML of a label next to the invalid item, or causing a red dot to appear next to the invalid item, is much more user friendly.
    It's not a long string of alerts, it's even worse; it is fix one field, get new error message when submitting for, fix the next field, etc.
  5. That error usually means that you have recursive functions that aren't stopping recursing, and it's almost always a programming or logic error. You might be trying to JSON-encode the window or document object, for example, that would do it (they link to each other). I've never hit the maximum stack size in a situation where I didn't make a mistake. The page took 6.7 seconds for me to load, but every request has significant latency. That usually means the connection to the server is too slow.
    No, that wouldn't do it. JSON.stringify has its own error message for cyclic structures, and it is also a TypeError.
  6. Again, that's a silly and unrealistic example. A practical example which is similar to that would be to insert an image before every external link warning the user that they would be leaving the site:

    img:not([href^="http://example.com"],[href^="/"]):before {    content: url('./imgs/external.png');}

    Note: You should not use gifs, either.

  7. callumacrae, I think everyone welcomes a seasoned developer on the board. But there are some matters you may wish to hold back on until you've absorbed more of the spirit of the board, who we are, and what the members are looking for.
    It is our responsibility as experienced developers to ensure that less experienced developers do not develop habit habits or make the same mistakes we did. The amount of time I have spent searching for incorrectly spelled variables... I did not "flog" him, merely pointed it out.
  8. it doesn't really matter if it is spelled wrong, per se. if it is spelled the same way all the way throughout the code (as in his example) then it wont cause any errors. If you're just out to be the spelling/grammar police, then do so more gracefully, since it's just a programming forum and there are no rules to how your actually name your variables, other than the required syntax of the language.
    What?Do you know why we have conventions on variable naming? I'll give you a clue: it isn't to make the code pretty.
  9. as replied, what's the problem? Where is your javascript code? What are you stuck on?
    OP originally posted a huge block of code with no whitespace, but has now edited it down to two seemingly irrelevant lines.
  10. Finally I made it (reset input date)!_________________________________________________________________________________________________________ // Here is my code: <script type="JavaScript"> function reset() { // Creat date datatype variable and set it to null value var a=new Date();a.setFullYear(0,0,0); // Get input date element and insert the variable a var b=document.getElementsByName("name")[0];b.value=a; } <script> <input type="date" name="date"> <button onclick="reset()">Reset Date</button>_________________________________________________________________________________________________________ @dsonesuk: Thank you for http://w3schools.com...ef_obj_date.asp @niche: Thank you I found out that innerHTML is only for changing text inside of an element.
    You shouldn't use the onclick attribute to add events, you should use the addEventListener function (and possibly .attachEvent if you want support for oldIE).
  11. What is CSS3 linear? Thanks.
    A linear gradient is a gradient which starts of at one colour, and then fades to another colour at a linear speed across the element: lineargradient2.png
    • Like 1
  12. The particular line looks OK. There probably is something wrong on the previous line of code.
    The validator doesn't always output the code exactly as it was (or it sometimes messes up the whitespace).
×
×
  • Create New...