Hi
I'm a bit tired and I can not find my mistake perhaps it is so simple but a little help on your part is required
Well, I want to check the validity of IP addresses entered by the user, but I do not recover when I want to do a concatenation like this :
The Hole HTA
Thank you !
I'm a bit tired and I can not find my mistake perhaps it is so simple but a little help on your part is required
Well, I want to check the validity of IP addresses entered by the user, but I do not recover when I want to do a concatenation like this :
Code:
Dim IP
Dim Masque
Dim Passerelle
Dim DNS1
Dim DNS2
IP = N1.Value &"."& N2.Value &"."& N3.Value &"."& N4.Value
Masque = N5.Value &"."& N6.Value &"."& N7.Value &"."& N8.Value
Passerelle = N9.Value &"."& N10.Value &"."& N11.Value &"."& N12.Value
DNS1 = N13.Value &"."& N14.Value &"."& N15.Value &"."& N16.Value
DNS2 = N17.Value &"."& N18.Value &"."& N19.Value &"."& N20.Value
The Hole HTA
Code:
<html>
<HTA:APPLICATION
APPLICATIONNAME="Set IP config"
SCROLL="no"
SINGLEINSTANCE="yes"
ICON="nslookup.exe"
MAXIMIZEBUTTON="no"
WINDOWSTATE="no">
<style type='text/css'>
input {width:21px;
border:0px;
font-size:10px;
background-color:lightcyan;
font-weight:bold;
text-align:center;
}
BODY {background:lightcyan;}
.button {
border-size: 0px;
border-style: none;
background: inherit;
width: 120px;
font-size:14px;
color: blue;
cursor: hand;
cursor: pointer;
padding: 0px;
}
</style>
</head>
<title>Saisie des adresses IP</title>
<META HTTP-EQUIV="MSThemeCompatible" CONTENT="YES">
<script language="VBScript">
Dim IP
Dim Masque
Dim Passerelle
Dim DNS1
Dim DNS2
IP = N1.Value &"."& N2.Value &"."& N3.Value &"."& N4.Value
Masque = N5.Value &"."& N6.Value &"."& N7.Value &"."& N8.Value
Passerelle = N9.Value &"."& N10.Value &"."& N11.Value &"."& N12.Value
DNS1 = N13.Value &"."& N14.Value &"."& N15.Value &"."& N16.Value
DNS2 = N17.Value &"."& N18.Value &"."& N19.Value &"."& N20.Value
Sub Window_OnLoad
CenterWindow 320,350
End Sub
Sub CenterWindow(x,y)
window.resizeTo x, y
iLeft = window.screen.availWidth/2 - x/2
itop = window.screen.availHeight/2 - y/2
window.moveTo ileft, itop
End Sub
Function IP_Valide(ip)
Set RegularExpressionObject = New RegExp
With RegularExpressionObject
.Pattern = "\b((25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(25[0-5]|2[0-4]\d|1?\d?\d)\b"
.IgnoreCase = False
If .Test(ip)= True then
IP_Valide = True
end if
End With
End Function
Sub CheckIP()
If Not IP_Valide(IP) Then
MsgBox IP
MsgBox "L'adresse IP que vous avez saisi "&IP&vbcr&" est non valide",16,"L'adresse IP que vous avez saisi est non valide"
N1.Focus()
End If
If Not IP_Valide(Masque) Then
MsgBox "L'adresse IP du masque sous-réseau que vous avez saisi est non valide",16,"L'adresse IP du masque sous-réseau que vous avez saisi est non valide"
MsgBox Masque
N2.Focus()
End If
If Not IP_Valide(Passerelle) Then
MsgBox "L'adresse IP de la Passerelle par défaut que vous avez saisi est non valide",16,"L'adresse IP de la Passerelle par défaut que vous avez saisi est non valide"
N3.Focus()
End If
If Not IP_Valide(DNS1) Then
MsgBox "L'adresse IP de DNS1 que vous avez saisi est non valide",16,"L'adresse IP de DNS1 que vous avez saisi est non valide"
N4.Focus()
End If
If Not IP_Valide(DNS2) Then
MsgBox "L'adresse IP de DNS2 que vous avez saisi est non valide",16,"L'adresse IP de DNS2 que vous avez saisi est non valide"
N5.Focus()
End If
If IP_Valide(IP) And IP_Valide(Masque) And IP_Valide(Passerelle) And IP_Valide(DNS1) And IP_Valide(DNS2) Then
MsgBox "IP : "&IP&vbCr&"Masque sous réseau : "&Masque&vbCr&"Passerelle par défaut : "&Passerelle&vbCr&_
"DNS1 : "& DNS1&vbCr&"DNS2 : "& DNS2,64,"Les @ IP"
End If
End Sub
</script>
<body>
<fieldset>
<legend>Utiliser l'adresse IP suivante</legend>
<table>
<tr>
<td><p style="float:left"><B>Adresse IP Locale :</B></p></td>
<td><div style="border:solid 1px gray;width:100px;"><input type='text' class="IP" maxLength="3" name="N1" /><b>.</b><input type='text' class="IP" maxLength="3" name="N2"/><b>.</b><input type='text' class="IP" maxLength="3" name="N3"/><b>.</b><input type='text' class="IP" maxLength="3" name="N4" />
</div></td>
</tr>
<tr>
<td><p style="float:left"><B>Masque sous-réseau :</B></p></td>
<td><div style="border:solid 1px gray;width:100px;"><input type='text' class="IP" maxLength="3" name="N5" /><b>.</b><input type='text' class="IP" maxLength="3" name="N6" /><b>.</b><input type='text' class="IP" maxLength="3" name="N7"/><b>.</b><input type='text' class="IP" maxLength="3" name="N8" />
</div></td>
</tr>
<tr>
<td><p style="float:left"><B>Passerelle par défaut :</B></p></td>
<td><div style="border:solid 1px gray;width:100px;"><input type='text' class="IP" maxLength="3" name="N9" /><b>.</b><input type='text' class="IP" maxLength="3" name="N10"/><b>.</b><input type='text' class="IP" maxLength="3" name="N11" /><b>.</b><input type='text' class="IP" maxLength="3" name="N12" />
</div></td>
</tr>
</table>
</fieldset>
<br>
<fieldset>
<legend>Utiliser l'adresse DNS suivante </legend>
<table>
<tr>
<td><p style="float:left"><B>Serveur DNS N° 1 : </B></p></td>
<td><div style="border:solid 1px gray;width:100px;"><input type='text' class="IP" maxLength="3" name="N13" /><b>.</b><input type='text' class="IP" maxLength="3" name="N14" /><b>.</b><input type='text' class="IP" maxLength="3" name="N15" /><b>.</b><input type='text' class="IP" maxLength="3" name="N16" />
</div></td>
</tr>
<tr>
<td><p style="float:left"><B>Serveur DNS N° 2 : </B></p></td>
<td><div style="border:solid 1px gray;width:100px;"><input type='text' class="IP" maxLength="3" name="N17" /><b>.</b><input type='text' class="IP" maxLength="3" name="N18" /><b>.</b><input type='text' class="IP" maxLength="3" name="N19" /><b>.</b><input type='text' class="IP" maxLength="3" name="N20" />
</div></td>
</tr>
</table>
</fieldset>
<br>
<center><input type="Submit" class="button" style="cursor:hand;" value="Vérifier les @IP" name="Check" onClick="CheckIP()" style="font-weight: bold">
<input type="button" class="button" style="cursor:hand;" value="IP Publique" name="Reload" onClick="TestConnexion()" style="font-weight: bold"><p>
<body>
</html>
Thank you !