Jump to content

dalawh

Members
  • Posts

    127
  • Joined

  • Last visited

Posts posted by dalawh

  1. Neither, it signifies the start of the string to test. The $ signifies the end, so the entire string must match the pattern rather than only part of the string matching.
    So when ^ is inside [], it means not and when ^ is outside of [], it means the start?
    Yes. The modifiers apply to the entire pattern.
    Without the i modifier, it will only accept the domain and tld in capitals right?
    In this case it's better to use a whitelist of allowed characters instead of trying to list every character that is not allowed.
    Oh. What I mean was, was it better to use [A-Z] and true means valid email or [^A-Z] and false means valid email. Pretty much the same, but different ways of looking at it. I realized that the way mentioned was better.
  2. It's a regular expression. It should cover a lot of cases. I use this one for e-mail validation. "$" indicates the end of the string, since an expression could match part of a string while there may be more characters after it.
    Thanks for the site. I think I will use this on: ^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$It seems to be the most accurate/useful one. Does the ^ apply to the whole expression or just the first []? I would assume the first []. On the site, it said:
    First, long regexes make it difficult to nicely format paragraphs. So I didn't include a-z in any of the three character classes. This regex is intended to be used with your regex engine's "case insensitive" option turned on. (You'd be surprised how many "bug" reports I get about that.)
    I may be misreading this, but does it say to use i as a modifier instead of adding a-z? If that is true, doesn't that affect the domain and tld meaning when I use test, it will always come back true since the domain and tld will always contain letters? When you use test function with the above expressions, how does it work? Does it only return one true/false or one for each of the []? For the domain and tld, wouldn't it be better to use ^ to prevent unwanted characters?
  3. I was looking through some ways to validate email. I saw the one on w3schools, but that is a basic one, so I started to code something more complicated adding all those if, else if, else statements, etc. Then I came across this...

    function validateEmail(email){var allowed=/^([a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$)/; return allowed.test(email);}

    Is something that simple sufficient enough? Everything seems to look as if it would work. Also, what does the "$" do?

  4. Actually JS is a bit odd. There is a substr() and a substring() and they are DIFFERENT.
    <!DOCTYPE html><html><body><script type="text/javascript">var str="0123456789";document.write(str.substring(1,4));document.write(" ");document.write(str.substr(1,4));</script></body></html>

    the output is "123 1234"

    Oooo, did not know this. Thanks for this :D
  5. I went over this plenty of times and no matter how many times I go over it, something goes wrong and I can't seem to figure it out.

    function validateEmail(email){var atNum=0;for(var i=0; i<email.length; i++){ //Checks for number of @  if(email.charAt(i)=="@"){   atNum++;  }}alert("atNum: " + atNum);var atPos=email.indexOf("@");alert("atPos: " + atPos);var lastDotPos=email.lastIndexOf(".");alert("lastDotPos: " + lastDotPos);var user=email.substr(0,atPos);alert("user: " + user);var domain=email.substr(atPos+1,lastDotPos-1); //<-- ISSUEfor(var i=atPos+1; i<lastDotPos; i++){  alert("email.charAt(" + i + "): " + email.charAt(i));}alert("domain: " + domain);var tld=email.substr(lastDotPos+1,email.length-1);alert("tld: " + tld);return false;}

    This is not fully functioning. Every time I run this, the domain always displays like gmail.com instead of gmail. I even tried to set the lastDotPos-1 to something I know that is suppose to give me gmail, but it still comes out as gmail.com. What is wrong?

  6. I'm sad to say our means of contacting the admins are the same as those of every other person. We don't have a "dedicated line". We can only hope that kaijim (who is really the only admin we're ever in contact with) sees the messages he receives are from us, and decides to prioritize them. We do have all the power we need though. Most of the stuff we have problems with is stuff that not even kaijim can single handedly fix either, but stuff Invisionzone must fix instead. That's something we have power over too. All users are initially locked until they pass a spam check, and we even have a warning about that on registration. Further locks (if any) are placed and released by mods, typically when said user blatantly breaks advertising rules (i.e. they spam).
    Oh okay. I didn't know mods could unlock accounts, but I am glad to know that. If mods can unlock accounts, I have no need for admins :) I forgot my password so I thought I try to guess it, but my account got locked before I got over 2 tries.
    :Pleased: you do know they're prolly working, just like any other human does, so if their really good at what they do, they will hardly be on here, thats why they appoint mods on each forum and if those mods end up being as busy as the others you pointed out that's not online, then you send an email and wait for a response. hope you understand Im Just Saying By The Way :good: so be happy we have mods on here and not like some forums i visit
    They haven't been active since last year... there is no e-mail... I don't understand where you are coming from. I love the 3 active mods. They help me out a lot.
  7. I'm not very knowledgeable about JS but as far as I understand the problem an end of line is a valid terminating character in JS, so a statement like a='<div> on a line by itself is not valid since there's an open quote. But JS has a line continuation character \ that tells it to ignore the default end of line and continue evaluating on the next line. Compare that with PHP which in most ways is very much like C in that white space (including newline characters) are ignored. A quote in PHP will automatically continue evaluating on the next line until a semicolon is reached. I don't particularly like the line termination features in JS but one has to live with what is. You'll need to affix a \ to that two line quote to avoid the error.
    Thanks for explaining this. Makes much more sense.
  8. There needs to be more active admins. It seems none of them are active. Only 3 mods are active and the rest disappeared. What happened? There needs to be a way for users to contact admins to unlock their account when it gets locked. Since the admins are not active, doesn't that mean it will never get unlocked?

  9. ??? I don't know what form/buttons has to do with centring navigation menu. The outer parent container is off centre to the white content area, the menu is centred to this outer parent container, it like comparing a car tyre being centred to the mudguard, but its not centred to the car body itself. IF i use web developer ruler it has equal distance from outer menu edges to outer parent container edges of 502px exactly.
    When I used a form and input, text-align:center did not work, but when I changed it to just buttons, it worked fine. Oh okay. I tried the same method and it was off a bit. Won't be needing it now, so it doesn't matter.
  10. Each statement/request passed to the browser, is seperated using semi-colon ( ; ), or by moving to the next line of the script (Its a way to denote one statement, from another). So when you write:
    a='<div>

    Lets say a variable is created, called 'a' and at the time the browser wants to create the string, that will be assigned to it, it finds out that you are missing the closing apostrophe, then it generate error.

    I am not missing a semi colon at the end. Not really sure where you are getting at.
  11. No, it is centred to the parent container it is in, the parent container has a margin that places it approx 25px away from the left side panel, while on the right the margin is about 10px;
    Wouldn't that make it not centered? You said the left margin was approx 25px and the right margin is 10px. It seems if I don't use form and use buttons instead, the text-align:center works fine.
  12. I notice when I try to store html code in a variable and there is an ENTER between any code, the code does not work. Example:

    function displayRegister(){var a='<div></div>';}

    Code above is fine.

    function displayRegister(){var a='<div></div>';}

    Code above does not work. Is there a reason for this?

  13. I've used this method lots of times, and it always centres for me? it depends what html elements you are using to centre, many come with default padding, margin and even text-indent, which require you to give a zero value, to truly centre.
    If you look at what they used, it is not centered. It is off to the right by a bit.
  14. vfNCJp.pngI have a form that looks like this. I currently have it set up using two div tags. The left side is one and the right side is another. If I have my cursor in the Email Address input and press TAB, it goes to Password input. I want to set it up where it looks exactly the same, but when I press TAB, it goes to Confirm Email Address input. Basically, I am wondering how I could align my page without using separate tags, so when I press TAB, it goes to the next one.
  15. Identical Comparison Operator: ===It compares the value and the type. I created a cookie and the value I used was 0. I compared it like this "if($_COOKIE['value']===0){ echo 'EQUAL';}". It seems to not be the same. Can anyone explain to me why? Aren't they both like integers?

  16. Yeah, you can do that if it is as simple as you described. I do it myself after user/administrator login. I evaluate the PUT and validate the login form, and then if password is successful (this is all before any output is generated) I'll redirect if login was successful. Otherwise I present the login form again and allow another attempt. You should be able to easily make all that work. Note that one PHP file = one PHP script. What you described is nothing more than a single script. You need a different URL to have a different script. My login.php redirects to index.php if login is successful.
    Okay, guess I will just have to redirect. 3 scripts and 2 redirects. Hope nothing gets more complicated than that.
  17. Yes, but you can only send that if you have not sent any HTML before it. You could JavaScript up a new request. There's lots of ways.
    There is no HTML involved until the very end. I take you step by step. User fills out a form and presses submit. I use a PHP script to get that information and create a cookie and redirect it (using header) to another script. This new script will log everything.and redirect (using header) to the HTML stuff. Is that fine? Any idea if we can have two separate PHP scripts in one PHP file like...
    <?php//CODE?><?php//CODE?>

×
×
  • Create New...