Solved

Input Field Substitution - II

Posted on 2003-12-09
5
164 Views
Last Modified: 2010-05-18
This week "mikosha" gave me this code below. It adds host "srv" to the domain name typed in an Input Field, hiddening this operation. It works nicely.

But, right now I found out that, whenever the data entered at the Input Field contains an hifen ( - ) it doesn't work. For instance, if I type a Server Name like "abc-company.com", it doesn't work.

If "mikosha" reads it I think he will fix quickly, but if someone else can help me I thank a lot in advance.

Mario./

<form>    
<input name="SERVER">
<input name="SERVER_UPD" type='hidden'>
<input type=button value=Replace onClick="mybutton_click(this.form)">
</form>
<script language='javascript'>
function mybutton_click(current_form){
   current_form .SERVER_UPD.value = this.form.SERVER.value.replace(/^(mail.|www.|srv.)*(\w+\.\w+)/i,'srv.$2');
   return true
}
</script>
0
Comment
Question by:multisites
  • 3
5 Comments
 
LVL 11

Accepted Solution

by:
Zontar earned 125 total points
ID: 9904083
current_form.SERVER_UPD.value = current_form.SERVER.value.replace(/^[mail|www]\.([\w|\-]+\.\w+)/i,'srv.$1');
0
 

Author Comment

by:multisites
ID: 9904271
Hhmm, Zontar, unhapilly it didn't work. I don't know if it has any sintax error. In order to make it easy to verify, I tried your code on this code, which doesn't hide the field.

The former code:

<form>    
<input name="SERVER">
<input type=button value=Replace onClick="this.form.SERVER.value=this.form.SERVER.value.replace(/^(mail.|www.|srv.)*(\w+\.\w+)/i,'srv.$2')">
</form>

Your new code:

<form>    
<input name="SERVER">
<input type=button value=Replace onClick="this.form.SERVER.value=this.form.SERVER.value.replace(/^[mail|www|srv]\.([\w|\-]+\.\w+)/i,'srv.$1')">
</form>

Thanks for helping.
0
 
LVL 1

Expert Comment

by:kellysgreen
ID: 9904738
Just appears to be a small typo  on Zontar's code offering.  Try this instead:

<input type=button value=Replace onClick="this.form.SERVER.value=this.form.SERVER.value.replace(/^[mail|www|srv]\.([\w|\-]+\.\w+)/i,'srv.$2')">

0
 

Author Comment

by:multisites
ID: 9905515
Hi:

The typo you mentioned was just changing $1 to $2 right? Well, sorry, it doesn't work. Thanks for further helping.

Mario./
0
 

Author Comment

by:multisites
ID: 9906114
Wow, after many attempts I got the right syntax. See:

<form>    
<input name="SERVER">
<input type=button value=Replace onClick="this.form.SERVER.value=this.form.SERVER.value.replace(/^(mail.|www.|srv.)*(\w+\.\w+|\w+\-\w+)/i,'srv.$2')">
</form>

Anyway, thanks a lot. Please, could the admin close this question?

Mario./
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question