Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating input mask for IP address on input field?

Status
Not open for further replies.

olmos

Technical User
Oct 25, 2000
135
US
How do I create an input mask for a user to enter an IP address for instance like this __.__.___.__ in the form field. Can coldfusion do something like this. I then want to strip out the decimal points to get it into Oracle since the IP field in the database is a number field. Any other suggestions on how to do this or if this is the way to go or not for an IP address field to get a user to enter the IP address correctly ?

Thank you in advance,
olmos

 
Hi Olmos,

Anything that occurs inside the browser on the client side is governed by the browser and you would need to do this with Java, Javascript, VB script, etc.. If you want to do it with just standard html so it works uniformly, you could do something like this:

<input type=&quot;text&quot; name=&quot;octet1&quot;>.<input type=&quot;text&quot; name=&quot;octet2&quot;>.<input type=&quot;text&quot; name=&quot;octet3&quot;>.<input type=&quot;text&quot; name=&quot;octet4&quot;>

On the receiving script, you could then insert them into the database with a dynamic query.

<cfquery ...
insert into table1
(ipNum) values('#octet1##octet2##octet3##octet4#')
</cfquery>

The only danger in converting an IP number into a number by removing the decimal points is that you lose the ability to retrieve the original IP. For exampe,

10.10.11.1 becomes 1010111
and
10.10.1.11 bceomes 1010111

which are identical after stripping out the decimal points.

Hope this helps,
GJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top