Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4547100
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:02:50+00:00 2026-05-21T16:02:50+00:00

Actually I want to validate username nd password only for my os1 == 2

  • 0

Actually I want to validate username nd password only for my os1 == 2 which is linux so please help me

if (os1 == 1) os = "Windows";

if (os1 == 2) os = "Linux";
if (os1 == 3) os = "Others";


function Validate() {

var dropdownIndex = document.getElementById('type').selectedIndex;
var sztype = document.getElementById('type')[dropdownIndex].value;

if (sztype == "1") {
    var szpassword = "";
    var szguid = "";
    var name = Trim(document.userform.name.value);

    var ip = Trim(document.userform.ip.value);
    if (ip.length == 0) {
        alert("Please specify IP/Host Name.");
        return false;
    }
    if (name.length == 0) {
        name = ip;
    }

    szusername = Trim(document.userform.username.value);

    if (szusername.length == 0) {
        alert("Please specify Username.");
        return false;
    }

    var szvalidchars = new RegExp("[~!@#$%^&*()+|{}:\"<>?,/;'=\\`]");
    if (szvalidchars.test(szusername)) {
        alert("Username cannot contain invalid characters.");
        return false;
    }

    szpassword = Trim(document.userform.password.value);
    if (szpassword.length == 0) {
        alert("Please specify Password.");
        return false;
    }

and I have a table like this

<form name="userform">
<table cellpadding="10" cellspacing="0" border="0" width="100%">
<tr>
    <td><table width="100%" cellpadding="0" cellspacing="0">
        <tr>
          <td style="padding-left:12px; padding-top:10px;  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px;">To add single/multipe physical server(s), enter the IP address/range of physical server(s).</td>
        </tr>
      </table></td>
  </tr>
    <tr>
    <td></br>
    <table border=0> 
    <tr>
        <td style="padding-left:20px; padding-top:5px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px;">Type: </td>
        <td style="padding-top:5px; padding-left:50px;">
        <select name="type" id="type" class="SelectList Width200" onchange="OnCbTpyeChange()">
        <?php
        foreach($type as $key => $value)
        {
            echo  "<option value=\"".$key."\"";
            echo">";
            echo $value;
            echo "</option>";
        }
        ?>
        </select>
        </td>
    </tr>
    </table>
    <table id="hostname_table" name="hostname_table" border=0>
    <tr>
        <td style="padding-left:20px; padding-top:10px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px;">Name: </td>
        <td style="padding-top:10px;">
        <input name="name" type="text" maxlength="50" >
        </td>
    </tr>
    <tr>
        <td style="padding-left:20px; padding-top:10px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px;">IP/Host Name: </td>
        <td style="padding-top:10px;">
        <input name="ip" type="text" maxlength="50" >
        </td>
    </tr>
    <tr>
        <td style="padding-left:20px; padding-top:10px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px;">User Name: </td>
        <td style="padding-top:10px;">
        <input name="username" type="text" maxlength="50" >
        </td>

    <tr>
        <td style="padding-left:20px; padding-top:10px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px;">Password: </td>
        <td style="padding-top:10px;">
        <input type="password" name="password" type="text" maxlength="50">
        </td>
    </tr>
    <tr>
        <td style="padding-left:20px; padding-top:10px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px;">OS: </td>
        <td style="padding-top:10px;">
        <select name="os" id="os" class="SelectList Width200">
        <?php
        foreach($ostype as $key => $value)
        {
            echo  "<option value=\"".$key."\"";

            echo">";
            echo $value;
            echo "</option>";
        }
        ?>
        </select>
        </td>
    </tr>
    </table>
    <table id="nwrange_table" name="nwrange_table" style="display:none">

        <tr>
            <td style="padding-left:20px; padding-top:10px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px;">Start IP Address: </td>
            <td style="padding-top:10px;">
            <input name="startip" type="text" maxlength="50" id='startip'>
            </td>
        </tr>
        <tr>
            <td style="padding-left:20px; padding-top:10px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px;">End IP Address: </td>
            <td style="padding-top:10px;">
            <input name="endip" type="text" maxlength="50" id='endip'>
            </td>
        </tr>
    </table>


    </td>
    </tr>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T16:02:51+00:00Added an answer on May 21, 2026 at 4:02 pm

    Try this:

    function Validate()
    {
        var dropdownIndex = document.getElementById('type').selectedIndex;
        var sztype = document.getElementById('type')[dropdownIndex].value;
    
        if(sztype == "1")
        {
            //var os1 = userform.os.selectedIndex;
            var dropdownosIndex = document.getElementById('os').selectedIndex;
            var os1 = document.getElementById('os')[dropdownosIndex].value;
    
            if (os1 == 1)
                os = "Windows";
    
            if (os1 == 2)
                os = "Linux";
    
            if (os1 == 3)
                os = "Others";
    
            var ip = Trim(document.userform.ip.value);
            szusername = Trim(document.userform.username.value);
            szpassword = Trim(document.userform.password.value);
    
            if(os != 'Linux')
            {
                if(ip.length == 0)
                {
                    alert("Please specify IP/Host Name.");
                    return false;
                }
                if(name.length == 0)
                {
                    name=ip;
                }
    
                if(szusername.length == 0)
                {
                    alert("Please specify Username.");
                    return false;
                }
    
                var szvalidchars = new RegExp("[~!@#$%^&*()+|{}:\"<>?,/;'=\\`]");
                if(szvalidchars.test(szusername))
                {
                    alert("Username cannot contain invalid characters.");
                    return false;
                }
    
                if(szpassword.length == 0)
                {
                    alert("Please specify Password.");
                    return false;
                }
            }
    
            var szpassword = "";
            var szguid = "";
            var name = Trim(document.userform.name.value);
    
            var hostid = "Physical";
            szHostName = hostid;
            szname = name;
            var os = "Others";
    
            params = "guid="+szguid+"&username="+szusername+"&password="+szpassword+"&ip="+ip+"&name="+name+"&os="+os ;
            //alert(params);
            document.body.style.cursor = 'wait';//change cursor to wait
    
            if(!http)
                http = CreateObject();
    
            nocache = Math.random();
    
            http.open('post', 'addvm.php');
            http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            http.setRequestHeader("Content-length", params.length);
            http.setRequestHeader("Connection", "close");
            http.onreadystatechange = SaveReply;
    
            http.send(params);
        }
    
        // Etc...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I actually want to generate random password using PHP uniqid() function $randomPassword = uniqid();
I don't mean an alias or function. I actually want to add an entire
Actually, I want to validate the Canadian postal code form field using jQuery validation.
I am just working with username-to-password validation scripting, and I don't want to mess
What I actually want to do is to redirect writes in a certain memory
Actually i want that, suppose i have a colorcode #FF3366. How can i examine
Actually I want to populate an array to fill up my table view, but
I want all the views of Row in OnListItemClick() Actually I want to change
Hi every one actually I want to make a com.google.gson.JsonArray of data:[1,2,3,4,5].How can i
I am using javascript for the first time.Actually i want to get the latitude

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.