Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #11 (permalink)  
Old June 10th, 2010, 09:24 AM
Authorized User
 
Join Date: Jan 2010
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to elizas
Default Numeric validation using Javascript

Basicallly When we trying to validate a form some time we need numeric validation for textbox.

We can validate textbox by onkeypress event of the control By checking whether the keycode of the key pressed as the user types falls within the range of the number keys 48-57(i.e 0-9 and '.') ,if not belong to that range it will return false then it will disable the keypress action
function NumericValidation(eventObj)
{
var keycode;

if(eventObj.keyCode) //For IE
keycode = eventObj.keyCode;
else if(eventObj.Which)
keycode = eventObj.Which; // For FireFox
else
keycode = eventObj.charCode; // Other Browser

Eliza
__________________
Cheers,
Eliza

Mindfire: India's Only Company to be both Apple Premier & Microsoft Gold certified.
Reply With Quote
  #12 (permalink)  
Old July 23rd, 2010, 11:13 AM
Registered User
 
Join Date: Sep 2009
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default HTML in Dynamic Table cells

Hi All,

I tried to add links to open local xml files in browser in a dynamic table cells. I need help. I tried all ways but I think I miss something.
I can open them without table just by document.write(xmlfile location).
Here is my code. please help.
function showResultsTable(searched, srchedname) {
// get the reference for the body
var mybody = document.getElementsByTagName("body")[0];

// creates a <table> element and a <tbody> element
mytable = document.createElement("table");
mytable.setAttribute('id', 'resulttable');
mytablebody = document.createElement("tbody");

// creating all cells
var mycurrent_cell = new Array();

for(var j = 0; j < srchedname.length; j++) {
// creates a <tr> element
mycurrent_row = document.createElement("tr");

mycurrent_cell[0] = document.createElement("td");
currenttext = document.createTextNode(j);
mycurrent_cell[0].appendChild(currenttext);
mycurrent_row.appendChild(mycurrent_cell[0]);


mycurrent_cell[1] = document.createElement("td");
link = document.createElement("a");
link.name = ""+srchedname[j]);
link.href = "C:\\AAA\\TestCasesList.xml";
mycurrent_cell[1].appendChild(link);
mycurrent_row.appendChild(mycurrent_cell[1]);

mycurrent_cell[2] = document.createElement("td");
currenttext = document.createTextNode(searched[j]);
mycurrent_cell[2].appendChild(currenttext);
mycurrent_row.appendChild(mycurrent_cell[2]);

// appends the row <tr> into <tbody>
mytablebody.appendChild(mycurrent_row);
}
// appends <tbody> into <table>
mytable.appendChild(mytablebody);
// appends <table> into <body>
mybody.appendChild(mytable);
// sets the border attribute of mytable to 2;
mytable.setAttribute("border", "2");

}
Reply With Quote
  #13 (permalink)  
Old October 30th, 2011, 07:24 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Lightbulb Why validate if it's only a number?

Hi all!
It's my first post here. I have a better way of validation. Why not validate the phone number's country and location too?
I wrote a blog on this.
validate phone number location using javascript

When this is applied, you can not only check if the input looks like a phone number, but you can also check which country does the number belong to. For USA numbers, you can even check the state of the number. I hope it helps everybody :-)
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting mobile phone number yukijocelyn C# 2005 0 May 28th, 2008 11:43 PM
Mobile number Validation dharmeshtandel C# 2 April 23rd, 2008 01:12 PM
phone number validation debjanib ASP.NET 1.0 and 1.1 Professional 0 June 6th, 2006 12:01 PM
reformat phone number netcrawler Classic ASP Databases 1 November 3rd, 2004 09:01 PM
Phone Number validation help. mar0364 Classic ASP Basics 1 July 25th, 2004 06:39 AM



All times are GMT -4. The time now is 05:44 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.