Share on Google+Share on Google+

gulshan kumar
javascript validation
1 Answer(s)      3 years and 8 months ago
Posted in : Java Beginners

I need to validate password with following conditions through java script:

min 6 characters, max 50 characters
must contain 1 letter
must contain 1 number
may contain special characters like !@#$%^&*()_+

Ads

View Answers

August 7, 2013 at 11:54 AM


      <html>
        <head>
        <title>Java Script Strong Password Validtion</title>
        </head>
        <head>
        <script>
          function display()
          {
              document.getElementById("displayarea").innerHTML = document.getElementById("username").value;    
              document.getElementById("username").value = "";
              document.getElementById("displayarea1").innerHTML = document.getElementById("password").value;    
              document.getElementById("password").value = "";

              }
           </script>
        <script language="javascript">
        function isStrongPassword()
        {

           var control = document.PasswordForm.password;
           var myString= control.value;


           var Stringlen = myString.length;
           var ValidateDigits = /[^0-9]/g;
           var ValidateSpChar = /[a-zA-Z0-9]/g;
           var ValidateChar = /[^a-zA-Z]/g;

           var digitString = myString.replace(ValidateDigits , "");
           var specialString = myString.replace(ValidateSpChar, "");
           var charString = myString.replace(ValidateChar, "");

           if(Stringlen > 50 || Stringlen < 6)
           {
           alert("Password length must be between 6-50 characters");
           control.value="";
           control.focus();
           return false;
           }
           if(specialString < 1)
           {
           alert("Passwords must include at least 1 special (#,@,&,$ etc) characters");
           control.value="";
           control.focus();
           return false;
           }
           if(digitString < 1)
           {
           alert("Passwords must include at least 1 numeric characters");
           control.value="";
           control.focus();
           return false;
           }
           else{
           display();
           }
        }
        </script>
        </Head>
           <h2 align="Center">Registration</h2>
         <body>
          <form id=form1 name=PasswordForm>
          <table align="center">

             <tr>
             <td>UserName:</td>
             <td><INPUT id=username name=username size="20"></td>
             </tr>

            <tr>
            <td>Password:</td>
            <td><INPUT id=password name=password size="20"></td>
            </tr>
            <tr>
            <td><INPUT id=register type=button value=Submit name=Submit onclick='javascript:isStrongPassword()'></td>
            </tr>
            </table>
            <table width="400px" align="center" border=0> 

            <tr style="background-color:#8FBC8F;">
                <td align="center"><b>User Name</b></td>
                <td align="center"><b>Password</b></td>
                </tr> 
                <tr>
                <td align="center"><div id="displayarea"></div></td>
                <td align="center"><div id="displayarea1"></div></td>
                </tr>
            </table>
            </form>
            </body>
            </html>









Related Tutorials/Questions & Answers:
javascript validation
javascript validation  validation of comparing dropdownlist and textbox in javascript
javascript validation
javascript validation  my problem is following code is my form i want validation and for email field it will check formate useing regularexpressions. <html> <script src="combovalidate1.js" type="text/javascript
Advertisements
javascript validation
javascript validation  How to do javascript validations to check whether the entered primary key is present in the database or not .Iam using jsp language
javascript validation
javascript validation  How to do javascript validations to check whether the entered primary key is present in the database or not .Iam using jsp language
JavaScript Form Validation
JavaScript Form Validation  JavaScript Form Validation
javascript validation
javascript validation  i have 4 buttons in my project like save,find,modify,clear and exit. Here my problem is i have to validate in javascript like if i click on save button an alert message should be displayed "DO YOU WANT
javascript validation
javascript validation  I need to validate password with following...;/script> <script language="javascript"> function...;<INPUT id=register type=button value=Submit name=Submit onclick='javascript
javascript for websites url validation
javascript for websites url validation  javascript for websites url validation   JavaScript Code for URL Validation **function isvalidurl(url) { return url.match(/^(ht|f)tps?:\/\/[a-z0-9-.]+.[a-z]{2,4}\/?([^\s<
Javascript validation code
Javascript validation code  Hi, I need a javascript validation code for the following fields 1)Name 2)Email 3)Mobile 4)City 5)State 6)Product type 7)submit button All should display enter the field required(like name required
Javascript validation code
Javascript validation code  Hi, I need a javascript validation code for the following fields 1)Name 2)Email 3)Mobile 4)City 5)State 6)Product type 7)submit button All should display enter the field required(like name required
simple javascript validation for numbers
simple javascript validation for numbers  simple javascript validation for register number   Here is a html code that accepts number from...; <title>Mobile number validation using regex</title> <script
javascript regex validation alphanumeric
javascript regex validation alphanumeric  How to write javascript regex validation for alphanumeric?   <html> <head> <title> alphanumeric validation using regex</title> <script type="text
javascript regex validation email
javascript regex validation email  How to write JavaScript regex validation for email?   <html> <head> <title>Email validation using regex</title> <script type="text/javascript">
Registration page with JavaScript Validation
Registration page with JavaScript Validation   HTML Registration page with JavaScript Validation - required source code   Registration page in HTML with JavaScript Validation source code <html> <head>
Validation probs in javascript
Validation probs in javascript  This is my sports1.jsp file <...; <HTML> <head> <SCRIPT language="javascript">... file my validation works correctly but when my validation fails i am getting
Javascript validation - Java Beginners
Javascript validation  Hi I have developed the following function for the validation of Zip code,the problem is, when user enters the valid zip code in first attempt, the background color of text box changes to green while I
yyyy-mm-dd validation in javascript
yyyy-mm-dd validation in javascript   My form return value like (2011-10-05)yyyy-mm-dd ... my End date greater than my start date.. How to do validation in javascript
Form Validation with JavaScript
Form Validation with JavaScript  I created a simple form including nine or ten fields in HTML, and i want to validate it in JavaScript. How can i do it? Thanks!!   Hi Friend, Try the following code: 1)register.html
Javascript validation - Java Beginners
Javascript validation  Hi, this is ragav and my doubt is: I am having a input type="file" text box in which the user can browse the required... or not in javascript? plz urgent..   Hi Friend, Try the following code
JavaScript Email Validation
JavaScript Email Validation...; In this section we are going to check email Validation using JavaScript. JavaScript allows to perform a client side validation of email Ids in several forms
javascript form validation
javascript form validation  How to validate radio button , dropdown list and list box using onsubmit event..please give me a sample example..If we do not select any option,it shows an error..   Hello Friend, Try
Alphanumeric Validation in JavaScript
Alphanumeric Validation in JavaScript In this tutorials we will discuss about alphanumeric validation in JavaScript. Sometimes it may occur when user have.... Alphanumeric validation means a field in the form can accept only numbers
how to give validation using javascript in swing
how to give validation using javascript in swing   how to give validation using javascript in swing....... can somebody give code for username and password validation using javscript and swing
PHP JavaScript form Validation - PHP
PHP JavaScript form Validation  Just looking for a general PHP JavaScript form Validation. How can I write external JavaScript Validation? Please suggest!  Hi Friend, 1) form Enter Name Enter Address
javascript-email validation - Java Beginners
javascript-email validation  give the detail explanation for this code: if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr... about email validation at: http://www.roseindia.net/jsp/valid-email-jsp.shtml
javascript date validation using regex
javascript date validation using regex  Hi, I want to validate the date using javascript. Please help.   <html> <head> <title>Validating Date format</title> <script type="text/javascript">
combox validation javascript code - JSP-Servlet
combox validation javascript code  hiiiiiii, I want a javascript code for combobox field validation for my Lotus Notes web page.... thnx  Hi This is the source code of combobox validation in javascript
start date and end date validation in javascript - Ajax
start date and end date validation in javascript  hi, i am doing web... validations in javascript. end date should be greater than start date if so less than... in google and i got some scripts but it is not good validation.  
JavaScript password validation
JavaScript password validation We are going to discuses about JavaScript password special characters validation. In this example we have created one "... used JavaScript password validation and check for an alphabet , number
validation
validation  validation
Form Validation With Java Script
the Validation in  JavaScript and  your Validation in JavaScript program... Form Validation With Java Script   .... It is the most important features in JavaScript . It provide the facilities 
Tutorials   
Java Spring Hibernate Struts Training What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? neo4j-server.properties file location SASLError using PLAIN: not-authorized how to convert war file into .exe file using java code

Ads

 
Advertisement null

Ads