473,386 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

/^\d+$/ - please explain what does it mean

Hi All,

Can some one please explain what exactly is the below line in bold means ,

Expand|Select|Wrap|Line Numbers
  1. var i = ctl.id;
  2. var j =g_form.getValue(i);
  3.  
  4. var port = j;
  5. if (/^\d+$/.test(port)){ ----- Please explain what is this
  6.   var k =parseInt(g_form.getValue(i));
  7.   if (k<1 || k>65000){
  8.   alert('Invalid Port Number: Value must be <= 65000');
  9.   g_form.clearValue(i);
  10.   }
  11. }
  12.  
  13. else{
  14.   var ports = port.split("-");
  15.   if ((/^\d+$/.test(ports[0])) && (/^\d+$/.test(ports[1])) && (ports[0] < ports[1]) && ports[0] <=65000 && ports[1] <=65000 ){}
  16.   else{
  17.   alert("Invalid Port Range: Please enter numeric value") ;
  18.   g_form.clearValue(i);
  19.   }
  20.   }
My Requirement is , port column in catalog table is just accepting numbers and numbers with - .

Now we need to have the below , please let me know how to get this done.
- An open-ended range of ports with Less Than or Greater than: >1023
- A combination of the above formats separated by commas: 21, 80-81, >1023
- Negate a single number: !80
May 29 '17 #1
11 1547
Dormilich
8,658 Expert Mod 8TB
there is no line in bold ...
May 29 '17 #2
Hi ,
Please see the lines below , what I was referring to .
if (/^\d+$/.test(port))
and
if ((/^\d+$/.test(ports[0])) && (/^\d+$/.test(ports[1])) && (ports[0] < ports[1]) && ports[0] <=65000 && ports[1] <=65000 ){}
else{
alert("Invalid Port Range: Please enter numeric value") ;
g_form.clearValue(i);
}
}

Please let me know what can I do to include 3 ranges I mentioned above.
May 29 '17 #3
Dormilich
8,658 Expert Mod 8TB
/^\d+$/ simply means: only digits.
May 29 '17 #4
Ok , Please let me know what I need to do for including below .

- An open-ended range of ports with Less Than or Greater than: >1023
- A combination of the above formats separated by commas: 21, 80-81, >1023
- Negate a single number: !80
May 29 '17 #5
Dormilich
8,658 Expert Mod 8TB
An open-ended range of ports with Less Than or Greater than: >1023
Negate a single number: !80
make a separate test for that

A combination of the above formats separated by commas: 21, 80-81, >1023
explode by ,, trim, and do validation for each item.
May 29 '17 #6
Sorry ,

I did not understand what you are trying to say .
An open-ended range of ports with Less Than or Greater than: >1023
Negate a single number: !80
make a separate test for that - How to test this.

A combination of the above formats separated by commas: 21, 80-81, >1023
explode by ,, trim, and do validation for each item. - Please explain how to do this.
May 29 '17 #7
Dormilich
8,658 Expert Mod 8TB
make a separate test for that - How to test this.
well, I expect you to be able to write an if() condition that tests if a number is not 80 ...


explode by ,, trim, and do validation for each item.
explode: https://developer.mozilla.org/en-US/...s/String/split
trim: https://developer.mozilla.org/de/doc...ts/String/Trim
for each: https://developer.mozilla.org/en-US/.../Array/forEach
May 29 '17 #8
Hi,

Please let me know how to achieve this
An open-ended range of ports with Less Than or Greater than: >1023.

Also , I am new to java script , can you please help
May 29 '17 #9
Dormilich
8,658 Expert Mod 8TB
that requirement is the same as "not 1023".
May 29 '17 #10
Actually we need to have > and < sysmbols included. ANy idea.
May 29 '17 #11
Dormilich
8,658 Expert Mod 8TB
it makes no sense to include > and < when it's not necessary.
May 29 '17 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Charles Hixson | last post by:
I'm getting a list that I build which when printed is displaying, well, e.g.: d = << , 'Do', 'not', 'remove', 'thi', '.', ] >> Clearly I have a problem with the truncation of the final this, but...
4
by: QQ | last post by:
for example ~CcMessage() {} Thanks a lot! I am a beginner for C++, so please forgive my stupid questions
6
by: wintaki | last post by:
Given int x; What does x evaluate to? If x is 0, it equals 0x31, the ascii value of '1'. So for some reason, x evaluates to *(y+x) where x is a non pointer/array type.
1
by: alex14 | last post by:
Hi could someone please tell me what the double colons :: in perl scripts mean and what do they do? kind regards alex
2
by: SMichal | last post by:
Hi, I'm starting from my application simple bat data...test.bat. This file (test.bat) should start another aplication app.exe. I'm starting the test.bat from my application with Start() method of...
9
by: plusk1008 | last post by:
I have finals next week and I am stuck on one question on my review sheet for excel. So once again I beg: Please, please, please, please, please, please, please, please, please, please someone help...
2
by: mantrid | last post by:
in some php script ive seen $something==@$somethingelse whereas something==$somethingelse works the same what does the use of the @ do? Sorry if this is a stupid question
0
by: hini | last post by:
Hello, I see the N' in many asp , sql scripts at the beginning of a string usually and I don't know what's its meaning, I could not find anything about it when seraching google because of the...
1
by: Daniel Brower | last post by:
I found documentation that uses the ^ notation after a type name. What does that notation mean? Daniel
1
by: Monica Pnade | last post by:
what does /^/ mean in perl?
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
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,...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.