can anyone give me a regex to validate the password with following conditions
1. password should have atleast one alphabet and atleast one digit.
2.password should be atleast 6 characters and maximum of 8.
3. also password can allow specialcharacte rs but it is not mandatory.
without spl.characters also password is valid but it should have atleast one alphabet and minimum 1 digit.
hope i am clear.
i tried with ctype_alnum() function in php but it is accepting if all characters or either alphabet or digit. but i want to enforce atleast one alphabet and one digit should be in password
can any one give me a regex for this pls.....
9 6615
at present i am trying with the following code
function isAlphaNumeric( $sInput)
{
if(false===(pre g_match("/[a-zA-Z]/", $sInput) > 0))
{
return false;
}
if(false===(pre g_match("/[0-9]/", $sInput) > 0))
{
return false;
}
return true;
}
can anyone improve it to suite my requirements which i specified above
now i am trying with the following - if(false===(preg_match("/^(?=.*\d)(?=.*[a-z]).{6,8}$/", $sInput) > 0))
-
{
-
return false;
-
}
it's working fine.
but i want to use the same expression in javascript also for client side validation
can any one tell me how i can use the same regular expression in javascript.
i am trying with following but it's not working - var regex=/\(?=.*\d\)\(?=.*[a-z]\).{6,8}/;
-
if(regex.test(pword))
-
{
-
alert("valid password");
-
}
-
else
-
{
-
alert("invalid password");
-
}
-
Hi
i have the following regex in php and it's working fine for me -
if(false===(preg_match("/^(?=.*\d)(?=.*[a-z]).{6,8}$/", $sInput) > 0))
-
{
-
return false;
-
}
but i want to use the same regex in javascript for the sake of client side validation
can anyone tell how i can use the same regex in java script
the regex should test the following in a password
1. password should contain atleast one numeric and one alphabet
2.password should be in between 6 to 8 characters
i am trying with the following but it's not working. -
var regex=/\(?=.*\d\)\(?=.*[a-z]\).{6,8}/;
-
if(regex.test(pword))
-
{
-
alert("valid");
-
}
-
else
-
{
-
alert("invalid");
-
}
try this
var regex = /(?=.*\d)(?=.*[a-z]).{6,8}/;
Markus 6,050
Recognized Expert Expert
First of all, kummu4help, we do not just happily 'hand out' code to anyone who asks for it. You have to show effort and understanding for us to help you.
Secondly, this is the PHP forum. If you're having problems with javascript, then you should go to javascript and ask.
Moderator.
acoder 16,027
Recognized Expert Moderator MVP
JavaScript doesn't support atomic grouping - see Regular Expressions JavaScript.
So you'll have to try to find a combination that could work in one go or use two separate tests.
Hi acoder,
the following regex was working fine for me in javascript.
i forgot to place the $ sign at the end
var regex=/\(?=.*\d\)\(?=. *[a-z]\).{6,8}$/;
if(regex.test(p word))
{
alert("valid");
}
else
{
alert("invalid" );
}
now i want to improve this so that it can work for caseinsensitive also.
but i don't know where to put the i (case insensitive) in the above regex
can u help me please....
acoder 16,027
Recognized Expert Moderator MVP
You also need an opening caret ^ at the beginning. For case-insensitive matches, use the i modifier, e.g. /^[a-z]+/i
acoder 16,027
Recognized Expert Moderator MVP
Merged threads since they're on the same topic.
Moderator.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Alan Pretre |
last post by:
Can anyone help me figure out a regex pattern for the following input
example:
xxx:a=b,c=d,yyy:e=f,zzz:www:g=h,i=j,l=m
I would want four matches from this:
1. xxx a=b,c=d
2. yyy e=f
3. zzz (empty)
4. www g=h,i=j,l=m
|
by: Lim Eng Teik |
last post by:
I was asked by a client to make changes for their Outlook Web Access page
where I need to validate Expiry Date of the Password and also the Password
Length for the NT Account Policy. Initially I use javascript to do a static
validation for the password expiry and password length. There request now
include dynamic changes to the Javascript where if the password length is
changed on the NT Account Policy, it will reflect on the client side...
|
by: brijesh |
last post by:
i am relatively new to javascript
i am trying for a password validation code
but iam not able to stop the page from loading the page when the
password is wrong. the code is as below
------------------
<html>
<head>
<title>New User</title>
<script language = "JavaScript">
function validatePasswords() {
|
by: Mike |
last post by:
I've been trying for the past week to put a simple code together. I
have done a LOT of searching, found scripts showing the functions I
would like to use, however when I mix them it all goes wrong, somehow
I always end up with error messages and functions not working right.
Can someone please help me?
I have a form, inside is 1 Text Field and 2 Password Fields. What I'm
looking to do is:
- Make sure password fields are equal
- Set...
|
by: engwar1 |
last post by:
Not sure where to ask this. Please suggest another newsgroup if this
isn't the best place for this question.
I'm new to both vb.net and regex. I need a regular expression that will
validate what people are entering as their new password.
Must be between 6 and 10 characters
Must be alphanumeric only
Can not be the word "password" in any case ie "pAsSworD" should also be
denied.
| |
by: Vishant |
last post by:
Hi,
I'm new to javascript and regEx and trying to solve the following
problem.
I have a function which validates the password if there is a number:
-------------------------------------------------
function findNumeric(str_obj){
regEx = /\d/;
if (str_obj.match(regEx))
|
by: jab3 |
last post by:
Hello. I"m new to this group, and to JavaScript in general, so please
forgive me if I breach local etiquette. I'm trying to implement some
client-side 'dynamic' validation on a form. I'm having a couple of
problems, which I'll try to describe. But this e-mail will only
reproduce one of them, in a "short" example. What I'm generally doing
is having each form entry contained in a div, which as a label, an
input with some event handlers,...
|
by: P2000 |
last post by:
I want to make a regex for the replace function that will replace any
"a" with "A" and any "b" with "B".
This is what I did so far... (I'm trying to learn this RegEx thing)
<form>
<input name="source" onkeyup="target.value=s.value.replace(/a/g,
'A')"/><br />
<input name="target" />
</form>
|
by: shwethatj |
last post by:
My problem is lik this ,
I am trying to create a registration form using javascript for a HR website , but i dont know how to provide password validation i.e the password and confirmation password entered by the user should match ...and also email validation i.e email id entered by user should be in correct format ... i know how to do using php but dont know using javascript ...
Can anyone help me ....
Regards,
Shwetha
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |