JavaScript - Zip Code Validation/formatting
hi,
i need US zip code formatting on my page. as zip code can be 5 digits or 5-4 digits, our requirement is that when user types in 6th digit, hyphen automatically gets added between 5th and 6th digit. ex: user enters 100161,it should become formatted as 10016-1 and then user can continue to add rest of digits. pls advice, highly appreciate. thanks Similar TutorialsI am trying to set up a looping structure that tests to see if the user enters a value. If the textbox is null then a global variable is false otherwise a checkbox is checked and the global variable is true. below is what i have done so far, please assist me. var isValid = false; window.onload = startForm; function startForm() { document.forms[0].firstName.focus(); document.forms[0].onsubmit = checkEntries; alert("You have been added to the list") } function checkEntries() { var menus = new Array(); var formObject = document.getElementsByTagName('*'); for (var i=0; i < formObject.length; i++){ if (formObject[i] == "myform") menus.push(formObject[i]); if (document.forms[0].firstName.value.length==0 || document.forms[0].firstName.value.length == null){ isValid= false; alert("Please enter a first name"); } else (document.forms[0].check0.checked=true); isValid=true; if (document.forms[0].lastName=="" || document.forms[0].lastName== null){ alert("Please enter a last name"); isValid = false; } else (document.forms[0].check1.checked=true); isValid=true; if (document.forms[0].email=="" || document.forms[0].email== null) { alert("Please enter a valid email"); } else return (document.forms[0].check0.checked=true); isValid=true; if (document.forms[0].bDate=="" || document.forms[0].bDate== null) { isValid=false; alert("please make sure you enter a valid birth date."); } else (document.forms[0].check0.checked=true); isValid=true; } } here is the form html... <form name="myform" > <input type="checkbox" name="check0" class="check0" id="check0" > First: <input type="text" name="firstName" id="firstName"> <BR> <input type="checkbox" name="check1" class="check1" id="check1" > Last: <input type="text" name="lastName" id="lastName" ><BR> <input type="checkbox" name="check2" class="check2" id="check2" > E-Mail: <input type="text" name="email" id="email"> <BR> <input type="checkbox" name="check3" class="check3" id="check3" > Birthday (mm/dd/yyyy): <input type="text" name="bDate" id="bDate"> <BR> <input type="submit" value="Join our mailing List" /> </form> I'd like to add validation for 5 digits (numbers only) to this code: if($("#newvalue1").val() == "" && operator == "Equals" || $("#newvalue2").val() == "" && operator == "Range" ){ good = false; alert("5 digits please."); I have tried the code below, but it's not working. Could anyone help, please? Thanks! if($("#newvalue1").val() == "" && operator == "Equals" || $("#newvalue2").val() == "" && operator == "Range" || $("#newvalue2").val() !/^\d{5} && operator == "Range" ){ good = false; alert("5 digits please."); Hello Everyone I am new on java script and I want to check the form blank text fields by using onChange event. Please guide me, is it possible or not....If possible then please send me the code. MY EMAILID IS dhiman.anurag1@gmail.com ........ THANK YOU Hello! There is something wrong in the code below. What is it? Can you help me please? The form validation was working just fine when I added the last 'if' for zip code validation. The function didn't work and returned true. The code is: Code: <script type="text/javascript"> function validateForm() { var y=document.forms["form"]["firstname"].value; var f=document.forms["form"]["zipcode"].value; var x=document.forms["form"]["email"].value; var atpos=x.indexOf("@"); var dotpos=x.lastIndexOf("."); if (y==null || y=="NAME") { alert("First name must be filled out"); return false; } if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length) { alert("Not a valid e-mail address"); return false; } } var re='/(^\d{5}$)/'; if (f!=re) { alert ("Not a valid address"); return false; } } </script> Any ideas or advice? Thank you in advance! Hi, I've been helped out and given a great code for part of the validation, the problem is I have tried to adapt it on subsequent fields and my validation has stopped working. I am including the email validation which works and then confirm email, select sex and select year of birth, none of the latter three work. I would be extremely grateful for any assistance as I am completely stuck. Code: <html> <head> <script type="text/javascript"> function check(form){ var email=form.email; if(!(/^([a-z0-9])([\w\.\-\+])+([a-z0-9])\@((\w)([\w\-]?)+\.)+([a-z]{2,4})$/i.test(email.value))){ form.email.value=""; alert("Please enter a valid email!"); myfield = email; setTimeout('myfield.focus();myfield.select();' , 10); return false; } var cemail=form.cemail; var cemailv=form.cemail.value; form.cemail.value=cemailv; if(!cemailv =="emailv") { form.pword.value=""; alert("Your email entries do not match!"); myfield = ln; setTimeout('myfield.focus();myfield.select();' , 10); return false; } var msex=form.msex; var msexv=form.msex.value; var fsex=form.fsex; var fsexv=form.fsex.value; if ((msexv==0 && fsexv==0)||(msexv=="" && fsexv=="")){ alert("Please select your sex!"); return false; } var DOBYear=form.DOBYear; if((var DOBYear==0)&&(varDOBYear>1993)){ alert("You have either not selected a year of birth or are not over eighteen years old!"); myfield = DOBYear; setTimeout('myfield.focus();myfield.select();' , 10); return false; } return true; } </script> </head> <body> <form action="guestdetails.php" name="form" onsubmit="return check(this)" method="post"> <fieldset class="two"> <legend>Your Information:</legend> <br /> <label class="two">Email:</label> <input type="text" class="input" name="email" value="enter email address" onclick="this.value='';" onfocus="this.select()" onblur="this.value=!this.value?'enter email address':this.value;" size="30%" /> <br /> <br /> <label class="two">Confirm Email:</label> <input type="text" class="input" name="cemail" value="confirm email address" onclick="this.value='';" onfocus="this.select()" onblur="this.value=!this.value?'confirm email address':this.value;" size="30%" /> <br /> <br /> <label class="two">Sex:</label> <br /> <label class="two">Male</label> <input type="radio" name="msex" value="male" onclick="1" /> <br /> <label class="two">Female</label> <input type="radio" name="fsex" value="female" onclick="1" > <br /> <br /> <select name="DoBYear" class="input"> <option value="0" selected"selected">Year</option> <option value="2009">2009</option> <option value="2008">2008</option> <option value="2007">2007</option> <option value="2006">2006</option> <option value="2005">2005</option> <option value="2004">2004</option> <option value="2003">2003</option> <option value="2002">2002</option> <option value="2001">2001</option> <option value="2000">2000</option> <option value="1999">1999</option> <option value="1998">1998</option> <option value="1997">1997</option> <option value="1996">1996</option> <option value="1995">1995</option> <option value="1994">1994</option> <option value="1993">1993</option> <option value="1992">1992</option> <option value="1991">1991</option> <option value="1990">1990</option> <option value="1989">1989</option> <option value="1988">1988</option> <option value="1987">1987</option> <option value="1986">1986</option> <option value="1985">1985</option> <option value="1984">1984</option> <option value="1983">1983</option> <option value="1982">1982</option> <option value="1981">1981</option> <option value="1980">1980</option> <option value="1979">1979</option> <option value="1978">1978</option> <option value="1977">1977</option> <option value="1976">1976</option> <option value="1975">1975</option> <option value="1974">1974</option> <option value="1973">1973</option> <option value="1972">1972</option> <option value="1971">1971</option> <option value="1970">1970</option> <option value="1969">1969</option> <option value="1968">1968</option> <option value="1967">1967</option> <option value="1966">1966</option> <option value="1965">1965</option> <option value="1964">1964</option> <option value="1963">1963</option> <option value="1962">1962</option> <option value="1961">1961</option> <option value="1960">1960</option> <option value="1959">1959</option> <option value="1958">1958</option> <option value="1957">1957</option> <option value="1956">1956</option> <option value="1955">1955</option> <option value="1954">1954</option> <option value="1953">1953</option> <option value="1952">1952</option> <option value="1951">1951</option> <option value="1950">1950</option> <option value="1949">1949</option> <option value="1948">1948</option> <option value="1947">1947</option> <option value="1946">1946</option> <option value="1945">1945</option> <option value="1944">1944</option> <option value="1943">1943</option> <option value="1942">1942</option> <option value="1941">1941</option> <option value="1940">1940</option> <option value="1939">1939</option> <option value="1938">1938</option> <option value="1937">1937</option> <option value="1936">1936</option> <option value="1935">1935</option> <option value="1934">1934</option> <option value="1933">1933</option> <option value="1932">1932</option> <option value="1931">1931</option> <option value="1930">1930</option> <option value="1929">1929</option> <option value="1928">1928</option> <option value="1927">1927</option> <option value="1926">1926</option> <option value="1925">1925</option> <option value="1924">1924</option> <option value="1923">1923</option> <option value="1922">1922</option> <option value="1921">1921</option> <option value="1920">1920</option> <option value="1919">1919</option> <option value="1918">1918</option> <option value="1917">1917</option> <option value="1916">1916</option> <option value="1915">1915</option> <option value="1914">1914</option> <option value="1913">1913</option> <option value="1912">1912</option> <option value="1911">1911</option> <option value="1910">1910</option> <option value="1909">1909</option> <option value="1908">1908</option> <option value="1907">1907</option> <option value="1906">1906</option> <option value="1905">1905</option> <option value="1904">1904</option> <option value="1903">1903</option> <option value="1902">1902</option> <option value="1901">1901</option> </select> <br /> <br /> <br /> </fieldset> <br /> <br /> <input type="submit" value="Submit"/> </form> <br /> <br /> </body> </html> I need help with a JavaScript form validation code. I am using the form validation code that is found on this page: http://www.dynamicdrive.com/dynamici...uiredcheck.htm The code works fine for me, but what I'm trying to do is add an additional condition to it. Currently, I just have the code set up to check if the user has enter their name, email, and phone number. But I also need it to validate something else only if a specific condition is true. On my form I have 2 different sets of Radio lists. One is called Function and the other radio list is called Design. If the user selects an option on one of the 2 lists, then it will be required for the user to also select an option from the 2nd list. The user CAN decide not to select anything from either radio list, but can not select from one list and NOT from the other. This is the If statement that I created (don't know if its correct or how to insert it to my current validation code). Code: <script type="text/javascript"> if (Function+Design<1 or == 400 or == 800) {document.write("Please select both a Function and Design Type");} </script> hello i have a form which when the user hits "submit," the info in the textboxes is entered to a database. the only textbox which is not entered to the DB is an "age" textbox, which i need to verify to see if user is 18yrs or older. if user is not 18 years or older, they get an alert telling them they arent 18+. if they are, then the form submits this is my code so far, and i dont get any alerts when i enter an age younger than 18: Code: <head> <script language="text/javascript"> var age; document.getElementById("userage").value = age; if (age >=18) document.location="feedbacksaveanddisplay.php"; else { alert('Sorry, we can not let you in!') document.location="content.html"; } </script> </head> <form method = "post" action = "FeedbackSaveAndDisplay.php"> <input type = "hidden" name = "user" value = "test"/> <input type = "hidden" name = "pwd" value = "test"/> <p>Enter your name, feedback, score</p> <table> <tr> <td>Name</td> <td> <input type = "text" name = "name" style="width:150px; height:20px;" /> </td> </tr> <tr> <td>Feedback</td> <td> <input type = "text" name = "feedback" style="width:150px; height:20px;" /> </td> </tr> <tr> <td>Score</td> <td> <input type = "text" name = "score" style="width:150px; height:20px;" /> </td> </tr> <tr> <td>Product</td> <td> <input type = "text" name = "product" style="width:150px; height:20px;" /> </td> </tr> <tr> <td>Age</td> <td> <input type = "text" name = "age" style="width:150px; height:20px;" /> </td> </tr> <tr> <td colspan = "2"> <input type = "submit" value = "Submit" /> </td> </tr> </table> </form> any tips/advice on how to fix my code? the problem i think is in the javascript... will greatly appreciate any help thanks!! I am trying to use some JavaScript code that I found by searching the web, my goal is to have a form with a "required" checkbox to force my users to acknowledge they have read my "Terms and Conditions" section. The code that I found ALMOST works properly - it does pop-up the "Alert" window when the checkbox is blank and the submit button is clicked... however, if the user closes the Alert window in order to click the checkbox in compliance, the "submit.form" command is executed before they have a chance. In other words, there is no "pause" in the execution of the script to allow the user to make the correction by clicking the checkbox. Here is the code: Code: <script LANGUAGE="JavaScript"> <!-- function ValidateForm(form){ ErrorText= ""; if ( form.terms.checked == false ) { alert ( "Please check the Terms & Conditions box." ); return false; } if (ErrorText= "") { form.submit() }} --> </script> Here is the HTML for the checkbox: Code: <input name="terms" type="checkbox" value="Yes" /> Here is the HTML for the submit button that calls the function: Code: <input type="submit" value="Continue" onclick="ValidateForm(this.form)" /> I've searched for other examples of code to accomplish this objective, but I'm hoping for a quicker solution by coming to the experts who can see the flaw in this JavaScript. Thanks for any help, Rob Working on college assignment, cant figure it out and need help! Basically a form that asks the user to fill in a valid email and password (ill give them the password), doesnt matter if it isnt secure, or if the email accepts dodgy emails (im just verifying the @ and a . and that is ok for the purpose of this. Anyway been trying with this code for ages now and cant see what is wrong but it isnt working, ive swapped it around and at times it does check that it is a valid email, sometimes it allows empty inputs. here is the code <script type="text/javascript"> function validateForm() { var x=document.forms["myForm"]["email"].value var y=document.forms["myForm"]["password"].value var atpos=x.indexOf("@"); var dotpos=x.lastIndexOf("."); if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length) { alert("Not a valid e-mail address"); return false; } </script> I think i need something like && (y!="123") around the 'if' statement, but not a clue how or where it goes. Basically im going to set the password to 123 so dont have to allow for caps etc. Easiest way to do this, anyone plleeeeeaaasseee?? Kind regards Alan Hi guys, I am working on my first validation form and although the Submit button works fine and puts me to the landing page, I don't get the alert, when nothing is checked. Please look at my code and help if you can. I really don't need anything fancy, just working Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="keywords" content="social media survey, social media, media survey, survey, danish media, danish media survey" /> <meta name="description" content="This survey is a school project, not an actual research. It has been designed to figure out the connection between the gender of the Danish users and their knowledge and usage of social media." /> <script language="JavaScript" type="text/javascript"></script> <script> function isRadioButtonSelected(radioGrpName, errorMsg){ var radios = document.getElementsByName(radioGrpName); var i; for (i=0; i<radios.length; i=i+1 ){ if (radios[i].checked){ return true; } } alert(errorMsg); return false; } function validate(){ if(isRadioButtonSelected('gender', 'please select your gender')){ return true; } return false; } </script> <title>The Social Media survey</title> <style type="text/css"> <!-- body { font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif; background: #8DC63F; margin: 0; padding: 0; color: #000; } } a img { border: none; } .container { width: 960px; margin: 0 auto; } .header { background: #FFF; margin-top: 30px; background-color:transparent; background-image:url(header.jpg); background-attachment: fixed; background-position:left center; background-repeat:no-repeat; } .content { padding-left: 50px; padding-right: 50px; padding-top: 30px; padding-bottom: 30px; background-color:#E7EFB9; font-family:Verdana, Geneva, sans-serif; font-size: 13px; } .footer { background: #FFF; } .fltrt { float: right; margin-left: 8px; } .fltlft { float: left; margin-right: 8px; } .clearfloat { clear:both; height:0; font-size: 1px; line-height: 0px; } </style> </head> <body> <div class="container"> <div class="header"><img src="header1.jpg" alt="The Social Media survey" width="960" height="175" /></div> <div class="content"> <form id="page1" action="http://projects.knord.dk/interaction/saveforminfo.aspx" onsubmit="return validate(); method="post"> <input type="hidden" name="surveyid" value="igakotra" /> <input type="hidden" name="landingpage" value="http://www.google.com" /> <input type="hidden" name="usecookie" value="true" /> <h3>1. Choose your gender</h3> <input type="radio" name="gender" value="male" id="male"/><label for "male">Male</label> <input type="radio" name="gender" value="female" id="female"/><label for "female">Female</label><br /><br /> <input type="submit" name="submit" value="Submit"/> </form> </div> <div class="footer"><a href="page1.html"><img src="1page.jpg" width="960" height="99" alt="1/6 pages" /></div> </div> </body> </html> I really need it asap... thanks guys, you're awesome here is the html code that i have PHP Code: <td valign="middle" valign="middle"> <input type="radio" name="gender" id="genderM" value="Male" /> Male <input type="radio" name="gender" id="genderFM" value="Female" /> Female </td> and here is the js funtion PHP Code: var $j = jQuery.noConflict(); function isValidEmail(str) { return (str.indexOf(".") > 2) && (str.indexOf("@") > 0); } function validateForm(){ var firstName; var lastName; var email; var mobile; var comment; var error; firstName = $j('#firstName').val(); lastName = $j('#lastName').val(); email = $j('#email').val(); mobile = $j('#mobile').val(); comment = $j('#comment').val(); if(firstName=='' || firstName.length < 3){ error = 'Please Enter Your First Name'; $j('#errormsg').html('<p class="errors">'+ error +'</p>'); return false; } if(lastName=='' || lastName.length < 3){ error = 'Please Enter Your Second Name'; $j('#errormsg').html('<p class="errors">'+ error +'</p>'); return false; } //mob //$jmob_pattern = '^\d{10}$j'; if(mobile.length != 10 || isNaN(mobile)){ error = 'Please Enter Your Mobile Number'; $j('#errormsg').html('<p class="errors">'+ error +'</p>'); return false; } if(email=='' || !isValidEmail(email)){ error = 'Please Enter Your Email Address'; $j('#errormsg').html('<p class="errors">'+ error +'</p>'); return false; } if(comment.length < 5){ error = 'Please Enter A Comment'; $j('#errormsg').html('<p class="errors">'+ error +'</p>'); return false; } return true; } Does anybody know how i check to see if the radio button is select and also can anybody tell me how i can check for an email in the correct format the function isValidEmail in the above alows emails to pass through if they are in this format aaa@aaa. i only want them to go through if they are aaa@aaa.com Thanks for your help if you give it Hi All, I have created my second Form to File Web Form thanks to some help from other members. Looks great. I am still new to HTML and Javascript, but basically I took my First Web Form coding (with the Java Script) and manipulated it so that it suited my needs for my 2nd Form (both are very close to being the same). For some reason, I can't get my Java Script validation to take effect. I was wondering if some one could try to pin point why it isn't functioning properly? Again it could be the most obvious thing, but please bear with me as I learn. Just for a little more clarity, I am going to list the things that I have changed to possibly make it easier to pin point: Added Fields: Department, SteetAddress, CityState Deleted: State/Research Accounts, Vendor Checkbox Modified: "Type" which is a radio button that I have changed the choices of. I beleive that's it...I will post my Java Script here and attach my Index File. Thank you in advance!! Code: /******************************************************************************** * * FORM VALIDATION * ********************************************************************************/ // get the value of a radio button group: function getRBValue(grp) { if ( grp.length == null ) return grp.checked ? grp.value : null; for ( var g = 0; g < grp.length; ++g ) { if ( grp[g].checked ) return grp[g].value; } return null; } // trim a string function trim(fld) { var val = fld.value.replace(/^\s+/,"").replace(/\s+%/,"").toUpperCase(); fld.value = val; return val; } var echk = /^([a-z][\w\-\'\.]*)+\@([a-z][\w\-\'\.]+\.)+[a-z]{2,6}$/i function emailCheck( fld ) { var email = trim( fld ); fld.value = email; return echk.test(email); } var digonly = /[^\d]/g function formatPhone( fld ) { var ph = fld.value.replace( digonly, "" ); if ( ph.length != 10 ) return; fld.value = "(" + ph.substring(0,3) + ") " + ph.substring(3,6) + "-" + ph.substring(6); } var phchk = /^\(\d\d\d\) \d\d\d\-\d\d\d\d$/ function phoneCheck( fld ) { return phchk.test(fld.value); } function validateForm( frm ) { var oops = ""; if ( trim( frm.elements["Username."] ).length < 5 ) oops += "You must enter your first and last name\n"; if ( ! emailCheck( frm.elements["Email."] ) ) oops += "That does not appear to be a valid email address\n"; if ( trim( frm.elements["Department."] ).length < 3) oops += "You must enter your department name\n"; if ( ! phoneCheck( frm.elements["Phone."] ) ) oops += "That is not a valid 10-digit phone number\n"; if ( trim( frm.elements["ShipToBuildingRoom."] ).length < 5 ) oops += "You must enter your building and room information\n"; if ( trim( frm.elements["StreetAddress."] ).length < 5 ) oops += "You must enter your street address information\n"; if ( trim( frm.elements["CityZip."] ).length < 5 ) oops += "You must enter your city and zip code information\n"; apptype = getRBValue( frm.elements["Type."] ); if ( apptype == null ) oops += "You must check one class\n"; var app = getRBValue( frm.RequireApprovalYesNo ); if ( app == null ) oops += "You must specify whether or not approval is required.\n"; if ( app == "Yes" ) { if ( trim( frm.Approver ).length < 5 ) oops += "You must enter the name of the approver\n"; if ( ! emailCheck( frm.ApprovalEmail ) ) oops += "The approval email is not a valid email address\n"; } } function showapp(yesno) { document.getElementById("APP1").style.display = document.getElementById("APP2").style.display = document.getElementById("APP3").style.display = yesno ? "" : "none"; } </SCRIPT> Hey all. I have a simple validation I need to do. I need to just make sure that a Checkbox is checked, and that a Text field has content. Sounds simple but I cannot find any thing that has a check and a text field. Here what I have. Can I modify this script to do this? A Checkbox MUST be checked and Text field MUST be filled out. This currently does the text field fine, but no Checkbox obviously. How can I add a checkbox validation to this? Thats it. Any help is appreciated. Code: <script type="text/javascript"> var textFields = ["digsig"]; function validateForm( ) { var oops = ""; // must initialize this! var form = document.sig; for ( var t = 0; t < textFields.length; ++t ) { var field = form[textFields[t]]; var value = field.value.replace(/^\s+/,"").replace(/\s+$/,""); // trim the input if ( value.length < 1 ) { oops += "You MUST enter your Digital Signature"; } } if ( oops != "" ) { alert("ERROR:" + oops); return false; } } } </script> Hello all, new here Seems like a very nice place to be apart of. I have my website www.gebcn.com. If you view source you will see all that I have done, but more importantly my problem. I have the JS code at the top there and I am unable to W3C validate my HTML because of the JS. I am using XHTML strict and would like to stay using it. The JS I have at the top is my form validation code. I am able to do any validating that I need with this "snippet" of code, I have shrank it from my library version just to use for this newsletter. Until now W3C validating was not important now for some reason it is and I am faced with this problem. I am not a Javascript guy more of a HTML/CSS guy and I can manipulate JS to suit my needs. <problem> I have tried to make this "snippet" of JS code an external file but receive multiple errors with the JS calling for the FORM NAME as it is not on the same page. The form NAME=NEWSLETTER is another problem, as W3C says I am unable to use attribute "NAME" in this location. <problem> I would like to keep the JS close to how it is now as I have a library to use this JS over and over again. Any pointers in the right direction or solutions to my problem would be greatly appreciated. Thanks! Hopefully it is not to hard huh If there is anything anyone needs, the code pasted here, or anything else please let me know. Thanks again! I can't figure out how to properly format the code below. I am looking to add breaks after where it says below. Also to change the color if possible. Any help would be much appreciated. function isPPC() { if (navigator.appVersion.indexOf("PPC") != -1) return true; else return false; } if(isPPC()) { document.write('<b>Send <A CLASS="contact" HREF=\"mailto:\?subject\=ADD A BREAK AFTER THIS ' + document.title + '?body= ADD A BREAK AFTER THIS ' + '\" onMouseOver="window.status=\'Send your friends e-mail about this page\'; return true" TITLE="Send your friends e-mail about this page">this page<\/A> to a friend</b>'); } else { document.write('<b>Send <A CLASS="contact" HREF=\"mailto:\?body\=ADD A BREAK AFTER THIS ' + document.title + ' ADD A BREAK AFTER THIS ' + '\" onMouseOver="window.status=\'Send your friends e-mail about this page\'; return true" TITLE="Send your friends e-mail about this page">this page<\/A> to a friend</b>'); } Hello, I wrote this script (well, not really wrote) Code: <script> <!-- var today_obj=new Date() var today_date=today_obj.getDate() var tips=new Array() var tiptitle='<img src="https://sites.google.com/site/psychally/home/10393545_s%20-%20Copy.jpg"> <b>.... Learn more at Psych Wiki</b><br><br>' tips[1]='Tip 1 goes here' tips[2]='Tip 2 goes here' tips[3]='Tip 3 goes here' tips[4]='Tip 4 goes here' tips[5]='Tip 5 goes here' tips[6]='Tip 6' tips[7]='Tip 7 goes here' tips[8]='Tip 8 goes here' tips[9]='Tip 9 goes here' tips[10]='Tip 10 goes here' tips[11]='Tip 11 goes here' tips[12]='Tip 12 goes here' tips[13]='Tip 13 goes here' tips[14]='Tip 14 goes here' tips[15]='Tip 15 goes here' tips[16]='Tip 16 goes here' tips[17]='Tip 17 goes here' tips[18]='Tip 18 goes here' tips[19]='Tip 19 goes here' tips[20]='Cotard Syndrome: The Cotard delusion or Cotards syndrome or Walking Corpse Syndrome is a rare neuro- psychiatric disorder in which people hold a delusional belief that they are dead (either figuratively or literally), do not exist, are putrefying, or have lost their blood or internal organs. In rare instances, it can include delusions of immortality.' tips[21]='Cotard Syndrome: The Cotard delusion or Cotards syndrome or Walking Corpse Syndrome is a rare neuro- psychiatric disorder in which people hold a delusional belief that they are dead (either figuratively or literally), do not exist, are putrefying, or have lost their blood or internal organs. In rare instances, it can include delusions of immortality.' tips[22]='Cotard Syndrome: The Cotard delusion or Cotards syndrome or Walking Corpse Syndrome is a rare neuro- psychiatric disorder in which people hold a delusional belief that they are dead (either figuratively or literally), do not exist, are putrefying, or have lost their blood or internal organs. In rare instances, it can include delusions of immortality.' tips[23]='Cotard Syndrome: The Cotard delusion or Cotards syndrome or Walking Corpse Syndrome is a rare neuro- psychiatric disorder in which people hold a delusional belief that they are dead (either figuratively or literally), do not exist, are putrefying, or have lost their blood or internal organs. In rare instances, it can include delusions of immortality.' tips[24]='Cotard Syndrome: The Cotard delusion or Cotards syndrome or Walking Corpse Syndrome is a rare neuro- psychiatric disorder in which people hold a delusional belief that they are dead (either figuratively or literally), do not exist, are putrefying, or have lost their blood or internal organs. In rare instances, it can include delusions of immortality.' tips[25]='Cotard Syndrome: The Cotard delusion or Cotards syndrome or Walking Corpse Syndrome is a rare neuro- psychiatric disorder in which people hold a delusional belief that they are dead (either figuratively or literally), do not exist, are putrefying, or have lost their blood or internal organs. In rare instances, it can include delusions of immortality.' tips[26]='Cotard Syndrome: The Cotard delusion or Cotards syndrome or Walking Corpse Syndrome is a rare neuro- psychiatric disorder in which people hold a delusional belief that they are dead (either figuratively or literally), do not exist, are putrefying, or have lost their blood or internal organs. In rare instances, it can include delusions of immortality.' tips[27]='Cotard Syndrome: The Cotard delusion or Cotards syndrome or Walking Corpse Syndrome is a rare neuro- psychiatric disorder in which people hold a delusional belief that they are dead (either figuratively or literally), do not exist, are putrefying, or have lost their blood or internal organs. In rare instances, it can include delusions of immortality.' tips[28]='Cotard Syndrome: \nThe Cotard delusion or Cotards syndrome or \nWalking Corpse Syndrome is a rare neuro- psychiatric disorder in which people hold a delusional belief that they are dead (either figuratively or literally), do not exist, are putrefying, or have lost their blood or internal organs. In rare instances, it can include delusions of immortality.' tips[29]='Cotard Syndrome: The Cotard delusion or Cotards syndrome or Walking Corpse Syndrome is a rare neuro- psychiatric disorder in which people hold a delusional belief that they are dead (either figuratively or literally), do not exist, are putrefying, or have lost their blood or internal organs. In rare instances, it can include delusions of immortality.' tips[30]='Cotard Syndrome: The Cotard delusion or Cotards syndrome or Walking Corpse Syndrome is a rare neuro- psychiatric disorder in which people hold a delusional belief that they are dead (either figuratively or literally), do not exist, are putrefying, or have lost their blood or internal organs. In rare instances, it can include delusions of immortality.' tips[31]='Cotard Syndrome: The Cotard delusion or Cotards syndrome or Walking Corpse Syndrome is a rare neuro- psychiatric disorder in which people hold a delusional belief that they are dead (either figuratively or literally), do not exist, are putrefying, or have lost their blood or internal organs. In rare instances, it can include delusions of immortality.' document.write(tiptitle) document.write(tips[today_date]) </script> Can someone please tell me how can I format the text that appears on the page from using the script? THANKS I have a password check on my join form but it looks ugly the idea is good but it is all unaligned and makes the form look bad. I was wondering if you guys can help me format it i tried my self but it just caused it to not work at all lol. Right now it looks like this: ---------------------------- | -------- bar color -------- | ---------------------------- GOOD PASSWORD What i want is it to appear like this: __________________________ | -------- Good Pass -------- | <- Color in the bg,words in the box! Code: (function(A){A.extend(A.fn,{pstrength:function(B){var B=A.extend({verdects:["Very weak","Weak","Medium","Strong","Very strong"],colors:["#f00","#c06","#f60","#3c0","#3f0"],scores:[10,15,30,40],common:["password","sex","god","123456","123","cute","gamer","qwerty","monkey", "apple"],minchar:6},B);return this.each(function(){var C=A(this).attr("id");A(this).after("");A(this).after("<div class=\"pstrength-info\" id=\""+C+"_text\"></div>");A(this).after("<div class=\"pstrength-bar\" id=\""+C+"_bar\" style=\"margin-top: 5px; border: 1px solid gray; font-size: 1px; height: 15px; width: 260px;\"></div>");A(this).keyup(function(){A.fn.runPassword(A(this).val(),C,B)})})},runPassword:function(D,F,C){nPerc=A.fn.checkPassword(D,C);var B="#"+F+"_bar";var E="#"+F+"_text";if(nPerc==-200){strColor="#000";strText="Unsafe password word!";A(B).css({width:"0%"})}else{if(nPerc<0&&nPerc>-199){strColor="#ccc";strText="Too short";A(B).css({width:"5%"})}else{if(nPerc<=C.scores[0]){strColor=C.colors[0];strText=C.verdects[0];A(B).css({width:"10%"})}else{if(nPerc>C.scores[0]&&nPerc<=C.scores[1]){strColor=C.colors[1];strText=C.verdects[1];A(B).css({width:"25%"})}else{if(nPerc>C.scores[1]&&nPerc<=C.scores[2]){strColor=C.colors[2];strText=C.verdects[2];A(B).css({width:"50%"})}else{if(nPerc>C.scores[2]&&nPerc<=C.scores[3]){strColor=C.colors[3];strText=C.verdects[3];A(B).css({width:"75%"})}else{strColor=C.colors[4];strText=C.verdects[4];A(B).css({width:"92%"})}}}}}}A(B).css({backgroundColor:strColor});A(E).html("<span style='color: "+strColor+";'>"+strText+"</span>")},checkPassword:function(C,B){var F=0;var E=B.verdects[0];if(C.length<B.minchar){F=(F-100)}else{if(C.length>=B.minchar&&C.length<=(B.minchar+2)){F=(F+6)}else{if(C.length>=(B.minchar+3)&&C.length<=(B.minchar+4)){F=(F+12)}else{if(C.length>=(B.minchar+5)){F=(F+18)}}}}if(C.match(/[a-z]/)){F=(F+1)}if(C.match(/[A-Z]/)){F=(F+5)}if(C.match(/\d+/)){F=(F+5)}if(C.match(/(.*[0-9].*[0-9].*[0-9])/)){F=(F+7)}if(C.match(/.[!,@,#,$,%,^,&,*,?,_,~]/)){F=(F+5)}if(C.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/)){F=(F+7)}if(C.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)){F=(F+2)}if(C.match(/([a-zA-Z])/)&&C.match(/([0-9])/)){F=(F+3)}if(C.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/)){F=(F+3)}for(var D=0;D<B.common.length;D++){if(C.toLowerCase()==B.common[D]){F=-200}}return F}})})(jQuery) Sorry about the code i know its cluttered lol. I have a string containing a date in the format YYYY-MM-DD and i want to format it so its something like 21st March 2012, how would i do this?
hi Guys, I have the following codes: var date1 = new Date(FromDate); My problem is 'new Date' function covering the date into mm/dd/yyyy format and I want it in dd/mm/yyyy format. any suggestion please, |