Jump to content

letsjustbereal

Members
  • Posts

    6
  • Joined

  • Last visited

letsjustbereal's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Thanks a lot mate! I have no idea why I wrote that! Now it makes sense.
  2. <form method="post" action="signup_process.php" class="ajax"> <p> Username: <input id="username" name="username" type="text" /> <span id="username_msg" class="<?php echo $class1; ?>"><?php echo $msg1; ?></span> </p> <p> Password: <input id="password" name="password" type="password"/> <span id="password_msg" class="<?php echo $class2; ?>"><?php echo $msg2; ?></span> </p> <p> <input id="submit" name="submit" type="submit" value="Submit"/> <span id="submit_msg" class="<?php echo $class3; ?>"><?php echo $msg3; ?></span> </p> </form> This is my form! (forgot to include it)
  3. window.onload = initialise;function initialise() { var fields = document.getElementsByTagName("input"); for (var i = 0; i < fields.length; i += 1) { var id = this.id; var msg = document.getElementById(id + "_msg"); /** * Now the function checkField() has access to * - the field -> through this * - the message -> through msg */ fields[i].addEventListener("blur", checkField(msg)); } }function checkField(msg) { if (this.value === "") { msg.innerHTML = "LOL"; }} Hello, Do you know Facebook? I am trying to recreate the same signup page that they have. If you try to signup but leave all fields empty and click on the signup button, some JavaScript code will stop you. Likewise, if you click on any of the fields and leave it empty, some JavaScript code will let you know that the field needs improving even before you click on submit. To achieve the same, I have decided to have a function called "checkField" that runs every time we trigger the "blur" event. (Later I will also make a function called "checkFields" that will check all fields when you click submit ..or all the fields that haven't been OKed yet). I want my code to work regardless of the actual id names and the amount of input fields present at any given time. What I have done so far does not work unfortunately. I think it's due to the fact that the variables "id" and "msg" get reset at every loop cycle, but I am not too sure. Anybody here kind enough to be able / willing to point me in the right direction? Would OOP techniques such as creating a class "Field" work? Any pointer would be very much appreciated. I am kind of new to JS and web dev so.. Cla
  4. it turns out it's not trivial to detect line breaks.. is there an easy way that you guys know that i can steal? Thanks
  5. and then use new line as separator. thanks!!!
  6. Hello, I want to create a RandomWord program in JavaScript. You click on the screen and a new random word appear on screen. For this I need a complete list of all English words (which I have). Now the most stupid idea would be to copy all those words into a file, and putting everything into an array and access the array with Math.random.. but it would take AGES to format every word to fit my criteria... Is there a way to neatly access the file, which is just a list of words each one on a new line and get the words out? Thanks a lot, ForR
×
×
  • Create New...