JavaScript - Validating Email Using Regexp In Javascript!
Can someone provide a code sample which uses RegExp in JavaScript to validate an email type of input in an HTML form?
Similar TutorialsHi, I'm wondering if someone can help me. I have recently used this tutorial: http://net.tutsplus.com/tutorials/ph...-confirmation/ to develop a more complex sign up form for a competition for a client. Basically, the way the validation has been done is different to many other validation methods I've used before and don't understand how to implement it, for some additional requirements. This is an example of the PHP validation code that I have altered, to suit my form requirements: Code: //quick/simple validation if(empty($code)){ $action['result'] = 'error'; array_push($text,'You forgot to enter your entry code'); } if(empty($name)){ $action['result'] = 'error'; array_push($text,'You forgot to enter your name'); } if(empty($email)){ $action['result'] = 'error'; array_push($text,'You forgot to enter your email address'); } This code only validates that there is content in those fields. But, for example on the 'entry code' field, I would like to put a maximum character input there and restrict certain characters, as well as a standard 'email' validation, so that the form is sent through to the database correctly. If anyone knows how I can do this, with this sign-up form in particular, please assist me, as every other method I've tried to work with this form hasn't worked and caused the form to error. Thank you in advance. First class assignment on regular expressions. I'm looking for help and teaching, not someone doing the assignment for me (see the code below for some of the work I've already done). I am attempting to do a basic email format validation in JavaScript on a very basic form with fields for name, address, email, etc. Requirements: A period can occur before the @, but not twice in a row -- as in jane.doe@xyz.com but not jane..doe@xyz.com. Email must start with a letter. I'm also allowing underscores and hyphens before the @, but I'm not worrying about whether there's only one of each -- I'm just allowing those. Must end in .com, .net, .org. Nothing else. Here's me flailing around: Code: \A[a-zA-Z](\w|[.]|-){2,}@\w{3,}.(com|net|org) \A[a-zA-Z]\w(-|.){2,}@\w{3,}.(com|net|org) \A[a-zA-Z](\w|[-]|[.]){2,}@\w{3,}.(com|net|org) \A[a-zA-Z](\w|-|.){3,}@\w{3,}.(com|net|org) \A[a-zA-Z](\w|-|\.){3,}@\w{3,}.(com|net|org) \A[a-zA-Z](\w|-|\.){3,}[^\.{2,}]@\w{3,}.(com|net|org) \A[a-zA-Z](\w|-|[^\.{2,}]){3,}@\w{3,}.(com|net|org) \A[a-zA-Z]\w{2,}@\w{3,}.(com|net|org) \A[a-zA-Z]([\w|\.|\-]{3,}\w{3,})@[a-zA-Z]{3,}.(com|net|org) ^(\w+(?:\.[\w-]+)*)@[a-zA-Z]{3,}.(com|net|org) I have read extensively on this site and several others and haven't found a solution to the "one and only one period allowed in succession, but not required" problem. I haven't found a successful way to limit periods to only 1 in a row yet still have the rest of the validation work properly. I get the symbols in general, but as a newbie can't seem to make them do this one thing that I want them to do. Thanks for any help that's going! Hi, I want to check the email address type in a contact form but want to reject it if it's from a certain domain I actually use this regexp : /^[a-zA-Z0-9_\.\-]+\@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,4}$/ (taken from the jquery validationengine) to check if the email address is correctly formated but I'd like to reject it if contains hotmail between the @ and the . I tried many things but couldn't get something that works. If anyone has an idea, it would be greatly appreciated. Chag Hello, I have a the following text that I got from a getElementById and innerHTML and I need to get the model name from this text. Code: <div class="widgetWrap"> <div class="group1"> <h3><span>2010 Ford Escape XLT</span></h3> <dl id="vPrice"> <dt>2010 Ford Escape XLT Prices</dt> The last line has the year make model and trim level, I need to be able to get the model, "Escape" from here. The problem is the model does change, and I need to get whatever the model says, Focus, Expedition and so on. The make may change also, Lincoln or Mercury. Is there an easy way to get just the model name whatever it may be? I have been working on this for a while, and just can't get it. Thanks for your help Marc Damon I cannot get the result right. I write area and phone by numbers but it still gives me error Code: function validate_text(field,alerttext) { with(field) { var re = /[a-zA-Z]/g; if(re.test(field)) { return true;}else{alert(alerttext);return false;} } } function validate_number(field,alerttext){ with(field) { var re = /[0-9]/g; if(re.test(field)) { return true;}else{alert(alerttext);return false;} } } function validateForm(thisForm){ with(thisForm) { if(validate_number(area,"wrong area code") == false) { area.focus();return false; } if(validate_number(phone,"wrong phone") == false) { phone.focus();return false; } if(validate_text(name_surname,"wrong name") == false) { name_surname.focus();return false; } } } Code: ...<b>Name Surname :</b><input style="margin-left:10px;" type="text" name="name_surname"/> <br /><br /> <b>phone :</b><input type="text" style="margin-left:19px;" maxlength="4" size="4" name="area" /> -<input type="text" style="margin-left:5px;" maxlength="7" size="10" name="phone" /><br /><br />.... I am trying to get an alert when user type a digit in my textbox and i made this code: <script type=text/javascript> <!-- function allowed(){ var str=document.getElementById('firstname').value; var patt=/[0-9]/g; if(patt.test(str)){alert(not allowed);}; } //--> </script> <body> <input type=text id=firstname /> <input type=button value=Submit onclick="allowed();" /> </body> But when i click the button then nothing happen. Please help me. Thanks. Hello I'm having a very simple RegExp problem. I have the text: Code: sddsfdfs[br][CARET][br]<i>[/quote]</i></div> And I want to match it against a Javascript RegExp: \[br\].*?\[\/quote\]<\/i> Note I used to the non-greedy quantifier ( ? ) for .* , such that it should match the minimum. I am expecting it therefore to match the first in the quote below, but instead it is matching the second: Code: 1. [br]<i>[/quote]</i> ------------------------------------------------- 2. [br][CARET][br]<i>[/quote]</i> I'm sure I've just missed something, I'd very grateful if someone could point out what this is? Thanks hi i need a help in java script. i have some text fields and when i enter the information in it and enter the validation button i need the results to be displayed in a box below these btns. Is it possible in Java script? Please see the attached image for some ideas. cheers <HTML> <HEAD> <TITLE>Form Validation Example </TITLE> <SCRIPT LANGUAGE="JavaScript"> <!-- function validateForm() { if(document.UD.FIRST_NAME.value=="") { alert("PLEASE FILL IN THE First Name FIELD"); return(false); }// validation for empty first name if(document.UD.LAST_NAME.value=="") { alert("PLEASE FILL IN THE Last Name FIELD"); return(false); }// validation for empty last name if(document.UD.MONTH.value=="") { alert("PLEASE FILL IN THE Birth Date FIELD"); return(false); }//validation for empty month if(document.UD.DAY.value=="") { alert("PLEASE FILL IN THE Birth Date FIELD"); return(false); } //validation for empty day if(document.UD.YEAR.value=="") { alert("PLEASE FILL IN THE Birth Date FIELD"); return(false); }//validation for empty year if(document.UD.MONTH.value >=1 && document.UD.MONTH.value <=12) { return(true); } else{ alert("Please enter a valid Month"); return(false); } /* this runs its course but stops after it makes this statement true. It does not continue the last to if statements. I have rearranged the code to read: if(document.UD.MONTH.value <=0) { alert("Please enter a valid Month"); return(false); } if(document.UD.MONTH.value >=12) { alert("Please anter a valid Month") return(false); } but by following these statments it skips these and goes straight to the next if statement and follows that until it reaches true then it won't go onto the last if statment.*/ if(document.UD.DAY.value >=1 && document.UD.DAY.value <=32) { return(true); } else{ alert("Please enter a valid day"); return(false); } if(document.UD.YEAR.value >=1900 && document.UD.YEAR.value <=2011) { return (true); } else { alert("Please enter a valid year"); return(false); } return(true); } //--> </SCRIPT> </HEAD> <BODY> <CENTER> <FONT SIZE="5" COLOR="#006600" FACE="verdana">Form Validation</FONT> </CENTER><BR><BR> <FORM METHOD=POST ACTION="http://www.mysite.com" NAME="UD"> <TABLE ALIGN="CENTER"> <TR> <TD>First Name</TD> <TD><INPUT TYPE="TEXT" NAME="FIRST_NAME"></TD> </TR> <TR> <TD>Last Name</TD> <TD><INPUT TYPE="TEXT" NAME="LAST_NAME"></TD> </TR> <TR> <TD>Birth Date</TD> <TD><INPUT TYPE="TEXT" SIZE="4" NAME="MONTH"><INPUT TYPE="TEXT" SIZE="4" NAME="DAY"><INPUT TYPE="TEXT" SIZE="6" NAME="YEAR"> </TD> </TR> <TR> <TD><INPUT TYPE="SUBMIT" VALUE="Submit Form" onClick="return validateForm()"></TD> <TD><INPUT TYPE="RESET" VALUE="Reset"></TD> </TR> </TABLE> </FORM> </BODY> </HTML> Above is my code. I have included a brief snippet of my problem in the code already, but basically my code runs through all the if statements until it gets to the if statement about the month and validating what numbers are used. Once it completes that if statement it returns true and goes no further. However if I rearrange my code it still does not work. If anyone has some idea on what I am doing I would greatly appreciate it. I am new to javascript and have been working on this for hours upon hours trying to figure it out so any help would be greatly appreciated. Thank you. hi im new to scripting so apologies if this is a basic question. I have a form which has javascript validation which triggers hidden divs if certain input boxes are left blank. I have it working with text fields and text areas, but im having trouble with a drop down menu. This is the code for my drop down: Code: <select name="department" size="1" id="department"> <option value="" selected>Please select</option> <option value="1">Personal Injury</option> <option value="2">ULR & Credit Hire</option> <option value="3">Consumer Credit</option> <option value="4">Health & Safety</option> <option value="5">Property</option> </select> And this is the code currently for the Javascript validating: Code: if(department.selectedIndex == 0){ var error = true; $('#department_error').fadeIn(500); }else{ $('#department_error').fadeOut(500); If i leave the drop down on the 'Please Select' value, the error message should show, but at the moment it doesnt show up. I have a feeling the syntax is wrong in the javascript? Any help very much appreciated Thanks hello everyone Im new to javascript as well as to this forum, Im coming here for first class help that I can only get from skilled programmers like you. I have a html form that uses javascript for validation, this is an assignment that consists of a form that sells hard drives from three different manufacturers, more specifically the part im stuck on is where if a manufacturer hoes have a number in the number of drives textbox, javascript needs to check to see that one of the radio buttons in that row is checked, if no radio button is checked an alert is displayed, however when I do select a radio button I still get the alert I used a "if...else if...else" construction but my logic is not well structured and thereby I get those problems, I have included the code down below if anyone is interested in helping a newbie out, thanks Code: <html> <head> <style type="text/css"> .bold {font-weight:bold ; font-family:"comic sans ms"} </style> <script type="text/javascript"> function number_of_drives() { //checks that a value is entered for at least one drive's manufacturer if(document.myform.drive1.value=="" && document.myform.drive2.value=="" && document.myform.drive3.value=="") { alert("please enter a quantity for the number of drives you wish to purchase from a manufacturer"); //if no value is entered in any the message is displayed return; //no further calculation is done } else if(isNaN(document.myform.drive1.value || document.myform.drive2.value || document.myform.drive3.value ))//verifies that only numeric values were entered { alert("make sure you enter a numeric values for the 'number of drives' column"); return; } else { if(document.myform.drive1.value !="" && document.myform.western[0].checked==false && document.myform.western[1].checked==false && document.myform.western[2].checked==false) alert("please select a size for the western digital drive"); else if(document.myform.drive2.value !="" && document.myform.maxtor[0].checked==false && document.myform.maxtor[1].checked==false && document.myform.maxtor[2].checked==false) alert("please select a size for the maxtor digital drive"); else if(document.myform.drive2.value !="" && document.myform.quantum[0].checked==false && document.myform.quantum[].checked==false && document.myform.quantum[2].checked==false) alert("please select a size for the quantum digital drive"); } } function check_radios()//function to check that a size is selected in the same row as the number of drives textbox//function to check that a size is selected in the same row as the number of drives textbox { if(document.myform.drive1!="" && document.myform.western[0].checked==false && document.myform.western[1].checked==false && document.myform.western[2].checked==false)// if drive1 textbox is not empty and no radio button is selected, a message will appear { alert("please select a size for the 'western digital' drive"); return; } else{return;} if(document.myform.drive2!="" && document.myform.maxtor[0].checked==false && document.myform.maxtor[1].checked==false && document.myform.maxtor[2].checked==false)// if drive2 textbox is not empty and no radio button is selected, a message will appear { alert("please select a size for the 'maxtor' drive"); return; } else{return;} if(document.myform.drive3!="" && document.myform.quantum[0].checked==false && document.myform.quantum[1].checked==false && document.myform.quantum[2].checked==false) // if drive2 textbox is not empty and no radio button is selected, a message will appear { alert("please select a size for the 'quantum' drive"); return; } else{return;} } function clear_form() { document.myform.western[0].value==""; document.myform.western[1].value==""; document.myform.western[2].value==""; document.myform.maxtor[0].value==""; document.myform.maxtor[1].value==""; document.myform.maxtor[2].value==""; document.myform.quantum[0].value==""; document.myform.quantum[1].value==""; document.myform.quantum[2].value==""; document.myform.drive1.value==""; document.myform.drive2.value==""; document.myform.drive3.value==""; document.myform.size1.value==""; document.myform.size2.value==""; document.myform.size3.value==""; document.myform.totalsize.value==""; document.myform.totalcost.value==""; document.myform.discount.value==""; document.myform.grandtotal.value==""; } </script> <title></title> </head> <body> <form name="myform"> <table align="center" border="1" width="80%"> <tr style="font-family:'comic sans ms'; font-size:24pt"><td align="center" colspan="6">Rupert's Hard Drive Emporium</td></tr> <tr><td class="bold" valign="middle" align="center" rowspan="2">Manufacturer</td><td colspan="3" align="center" class="bold">Drive Size</td><td rowspan="2" class="bold">Number of Drivers</td><td rowspan="2" class="bold">Number of GB</td></tr> <tr><td class="bold">500 Gigabytes</td><td class="bold">1 Terabyte</td><td class="bold">2 Terabytes</td></tr> <tr><td>Western Digital ($0.12/GB)</td><td align="center"><INPUT TYPE=RADIO NAME="western" value="500" /></td><td align="center"><INPUT TYPE=RADIO NAME="western" value="1024"/></td><td align="center"><INPUT TYPE=RADIO NAME="western" value="2048"/></td><td align="center"><input type="text" name="drive1"/></td><td align="center"><input type="text" name="size1"/></td></tr> <tr><td>Maxtor ($0.16/GB)</td><td align="center"><INPUT TYPE=RADIO NAME="maxtor" value="500"/></td><td align="center"><INPUT TYPE=RADIO NAME="maxtor" value="1024"/></td><td align="center"><INPUT TYPE=RADIO NAME="maxtor" value="2048"/></td><td align="center"><input type="text" name="drive2"/></td><td align="center"><input type="text" name="size2"/></td></tr> <tr><td>Quantum ($0.09/GB)</td><td align="center"><INPUT TYPE=RADIO NAME="quantum" value="500"/></td><td align="center"><INPUT TYPE=RADIO NAME="quantum" value="1024"/></td><td align="center"><INPUT TYPE=RADIO NAME="quantum" value="2048"/></td><td align="center"><input type="text" name="drive3"/></td><td align="center"><input type="text" name="size3"/></td></tr> <tr><td rowspan="4" align="center"><img src="hardisk.jpg" height="120pt" width="90pt"/></td><td colspan="3" align="right">Total Gigabytes Purchased</td><td align="center" colspan="2"><input type="text" name="totalsize" readonly="true"/></td></tr> <tr><td colspan="3" align="right">Total Cost of Drives</td><td align="center" colspan="2"><input type="text" name="totalcost" readonly="true"/></td></tr> <tr><td colspan="3" align="right">Discount</td><td align="center" colspan="2"><input type="text" name="discount" readonly="true"/></td></tr> <tr><td colspan="3" align="right">Grand Total</td><td align="center" colspan="2"><input type="text" name="grandtotal" readonly="true"/></td></tr> <tr><td align="center"><input type="submit" value="calculate" onclick="number_of_drives()"/></td><td align="center" colspan="5"><input type="submit" value="clear the form" onclick="clear_form()"/></td></tr> </table> </form> </body> </html> Hello @all readers, i'm trying to extract some text out of an options-selectmenu. The text of these option menus are pulled out of a webdb. For each option there excist a main value,for each main value, there excist an aditional price,either a minus (-) or a plus (+) to the main price: main item: graphiccard price 200,- options: 16 Mb (- 10) 32 Mb (main price,no need to get aditional value) 64 Mb (+ 50) 128 Mb (+ 100) So if user choose 128 MB (+ 100) i require a var that say's : 128 MB a var that say's: + a var that say's : 100 All selected options could contain many variants, it isnt pinned to the sample above,however,all options are formatted like this: someTextAndMabyNumbers_1 (aPlusOrMinusSign_2 AlwaysaNumber_3) I would apreciate to get a solution to this problem. I am not programming for living,the end result is for community.(oscommerce) To see a live version , ask me for the url (incase of seen as spam i not post until aprovement) Here is the code i pull out from the selectmenu,all alternative methodes instead of using regexp are much welcome. Code when clicked submit button and the regexp result var comes: Code: $("#submitme").live('click', function() { var mystringId = prodID; var addedOn = new Date(); $('select').each(function() { var selectId= $(this).attr("id"); var selectedOption = $(this).find('option:selected'); var selectedOptionValue = selectedOption.val(); mystringId += '{' + selectId + '}' + selectedOptionValue; }); db.transaction(function(tx) { tx.executeSql('SELECT COUNT(*) AS total FROM customers_basket WHERE products_unique_id ="'+ mystringId +'"', [], function (tx, results) { total = results.rows.item(0)['total']; if (total == 0){ $('select').each(function() { var selectName= $(this).attr("name"); var selectId= $(this).attr("id"); var selectedOption = $(this).find('option:selected'); var selectedOptionValue = selectedOption.val(); var selectedOptionText = selectedOption.text(); db.transaction(function(tx) { tx.executeSql('INSERT INTO customers_basket_attributes (customers_id, products_id, products_unique_id, customers_basket_quantity, products_options_id, products_options_txt, products_options_value_id, products_options_value_txt) values ("1" , "'+prodID+'" , "'+mystringId+'" ,"1", "'+selectId+'" , "'+selectName+'" , "'+selectedOptionValue+'" , "'+selectedOptionText+'")'); }); }); db.transaction(function(tx) { tx.executeSql('INSERT INTO customers_basket (customers_id, products_id, products_unique_id, customers_basket_quantity, final_price, customers_basket_date_added) values ("1" , "'+prodID+'" , "'+mystringId+'" , "1" , "0" , "'+addedOn+'")'); }); }else{ tx.executeSql('UPDATE customers_basket SET customers_basket_quantity = customers_basket_quantity + 1 WHERE products_unique_id ="'+ mystringId +'"'); tx.executeSql('UPDATE customers_basket_attributes SET customers_basket_quantity = customers_basket_quantity + 1 WHERE products_unique_id ="'+ mystringId +'"'); } }); }); $('.ui-dialog').dialog('close'); }); Code where the option selectmenu is generated: option.text(val+ ' (' +prefix+ ' ' +price+ ') '); representing the required regexp / alternativecode Code: for(key in products_options_array) { var value=products_options_array[key]; prodOpId = value['products_options_id']; prodOpName = value['products_options_name']; prodOpValueId = value['products_options_values_id']; prodOpValueName = value['products_options_values_name']; prodOpValuePrice = value['options_values_price']; prodOpValuePrefix = value['price_prefix']; var arr = [ { optionname: prodOpName, optionvalue: prodOpValueName, optionnameid: prodOpId, optionvalueprice: prodOpValuePrice, optionvaluepriceprefix: prodOpValuePrefix, } ]; for (var i = 0; i < arr.length; i++) { var r = arr[i]; //console.log(r); name = r.optionname; val = r.optionvalue; nameid = r.optionnameid; valueid = r.optionvalueid; price = r.optionvalueprice; prefix = r.optionvaluepriceprefix; if ($("#prodAttributes_"+prodID+" select").is("[name*=" + name + "]")) { var select = $("#prodAttributes_"+prodID).find("select[name*=" + name + "]"); var option = $("<option>"); option.val(valueid); if (price == 0){ option.text(val); }else{ option.text(val+ ' (' +prefix+ ' ' +price+ ') '); } select.append(option); } else { var select = $("<select>"); select.attr("name", name); select.attr("id", nameid); var option = $("<option>"); option.val(valueid); if (price == 0){ option.text(val); }else{ option.text(val+ ' (' +prefix+ ' ' +price+ ') '); } select.append(option); var label = $("<label>"); label.attr("class", "select"); label.attr("for", name); label.text(name); fieldset.append(select); myform.append(div); $(myform).appendTo("#prodAttributes_"+prodID); } } } myform.append(myinput); myform.trigger('create'); Thank you verry much!!!!!!!!! I was wondering if anyone could help me with regexp: 1)I would like it so that both a first and last name can be entered and that both ' and - can be included 2)I would like it so that addresses have to start with a number and then each word afterwards has to start with a capital letter and can include full stops, ' and - Any help is appreciated! I would like to perform a regular expression on a string and if TRUE do something. I have huge amounts of knowledge doing this in PHP but trying out javascript. Much appreciated. Hi all, I am having trouble understanding how to get RegExp to work. I've read so many tutorials but none have been clear. They all just explain the patterns you can check for but not how to piece them together! I am trying to write a RegExp pattern that checks an email address so that it allows the characters a-zA-z0-9_ before and after the @ How would I go about doing this? I tried Code: new RegExp("[a-zA-z0-9_].+@[a-zA-z0-9_].+"); but that didnt work. I appreciate any help I am using in script http://www.vicsjavascripts.org.uk/Wo...ordToolTip.htm Code: for (;z0<wary.length;z0++){ reg=new RegExp('\\b'+wary[z0][0]+'\\b','g'); html=html.replace(reg,'<a>'+wary[z0][0]+'</a>'); } html=html.replace(/zxc/g,'<'); I expected to be able to use Code: for (;z0<wary.length;z0++){ reg=new RegExp('\\b'+wary[z0][0]+'\\b','gi'); html=html.replace(reg,'<a>$1</a>'); } html=html.replace(/zxc/g,'<'); where $1 = the replaced text can someone please explain? Code: <html> <head> <script> function testemail(){ var fld= document.getElementById("input1").value; var reg = /^[\w+]@[\w+].com$/i; if(reg.test(fld)) { alert("email is ok"); } else { alert("email is not correct"); } } </script> </head> <body> <p> <form name="form1" onsubmit="testemail()"> enter email : <input id="input1" type="text" /> <input id="input2" type="submit" value="Submit" /> </form> </p> </body> </html> I am trying to test an email ID with above RegExp. I enter a correct email or not, I am always getting message "email is not correct" So RegExp is not working. How can I find out whats wrong with this RegExp ? Is there any tool to figure that out ? I tried with FireBug, but it does not point to whats wrong with RegExp Thanks Hello there I'm trying to build a simple little bot that you can ask questions. I'm using the indexOf method but I'm not sure if this is the best option for what I'm trying to do. If you type 'hello' or 'how are you' it answers. Any other input results in 'Dreadfully sorry but I didn't catch that. Say again?'. Is there a way that I can search input for certain words or combinations of words and trigger a single answer? Any help appreciated. <!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" /> <title>Bot</title> <script type="text/javascript"> function bot(go){var a = go.getElementsByTagName('input');var q = a[0];var t = q.value.toLowerCase();document.go.reset();if(t.indexOf('hello')!=-1){document.getElementById('bot').innerHTML = "Hello to you.";return false;}if(t.indexOf('how are you')!=-1){document.getElementById('bot').innerHTML = "I am functioning within acceptable parameters, thank you.";return false;};go.action=document.getElementById('bot').innerHTML = "Dreadfully sorry but I didn't catch that. Say again?"; return false;}; </SCRIPT> </head> <body onLoad="document.go.q.focus()"> <div align="center"> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <form name="go" onsubmit='return bot(go)' id="go" action=""><input name='q' type='text' /><input name='' type='hidden' /></form> <p> </p><div id="bot" align="center"></div> </div> </body> how about getting the attributes of the a tag? href and title and the innerhtml (actually the innerhtml has space on both ends)
Hey there, I'm looking to have some functionality similar to Twitter in that pages are loaded through ajax depending on the path that is shown in the URI hash. For example: http://twitter.com/#!/BarackObama/following I could just split the string by "/" but I want it to work if you enter a bunch of forward slashes as well, or none at all (only for the first forward slash), here's an example: http://twitter.com/#///////////BarackObama/following http://twitter.com/#BarackObama/following http://twitter.com/#/BarackObama The hash would be broken down into multiple parts, the first parameter (ie. BarackObama) would be the first returned value from the match, the second would be the rest of the parameters. Here are examples of what the hash would be, and what I would like in return. Hash: 1. http://twitter.com/#/BarackObama/following/test 2. http://twitter.com/#///////////BarackObama/following 3. http://twitter.com/#BarackObama Returned value from RegExp match: 1. BarackObama,following/test 2. BarackObama,following 3. BarackObama Hope that makes it pretty clear. I also have this so far, but it returns both a comma separated list, but also the original string. Code: /([0-9A-z]+)\/?(.*)/ |