473,398 Members | 2,088 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,398 software developers and data experts.

I'm a VB/Notes guy looking for the equivalent of Like and/or @Contains in JS

I'm working on Input Validation using the JS Header in my Notes app. I originally had formulas in Notes that was doing this, but now I've taken it to the web. So, after redoing the majority of the formulas in JS, I came to one input validation that wasn't within the realm of comparisons in JS. I'm looking that if mystr contains "." then alert, etc. But I can't seem to find anything in JS that is similar. Please advise. Thank you for your help!
Apr 22 '08 #1
5 1236
gits
5,390 Expert Mod 4TB
hi ...

you may use a regExp for this, like:

Expand|Select|Wrap|Line Numbers
  1. var s = 'my.string';
  2.  
  3. var val = /[.]/g.test(s);
  4.  
  5. // now val is true here
  6.  
have a look here for more details. you could even use indexOf();

Expand|Select|Wrap|Line Numbers
  1. var s = 'my.string';
  2.  
  3. var val = s.indexOf('.');
  4.  
  5. // val is 2 here ... when there is no . then it would be -1
  6.  
kind regards
Apr 22 '08 #2
hi ...

you may use a regExp for this, like:

Expand|Select|Wrap|Line Numbers
  1. var s = 'my.string';
  2.  
  3. var val = /[.]/g.test(s);
  4.  
  5. // now val is true here
  6.  
have a look here for more details. you could even use indexOf();

Expand|Select|Wrap|Line Numbers
  1. var s = 'my.string';
  2.  
  3. var val = s.indexOf('.');
  4.  
  5. // val is 2 here ... when there is no . then it would be -1
  6.  
kind regards
thank you
here is what I have
Expand|Select|Wrap|Line Numbers
  1.            var dcm = /^.$/
  2.             form = document.forms[0];
  3.             objField = form.QtyLb;
  4.             if( objField.match(dcm)) {
  5.                         objField.focus();
  6.                         alert("Please adjust your weight to whole number.");
  7.                         return false; 
  8.             }
how would I go about plugging in what you offered given the input validation I have?
Apr 22 '08 #3
gits
5,390 Expert Mod 4TB
what do you really want to check? your current regEx matches a single point ... ?
Apr 22 '08 #4
what do you really want to check? your current regEx matches a single point ... ?
If what is entered has a decimal point. That is what I'm looking to check for.
Apr 23 '08 #5
gits
5,390 Expert Mod 4TB
the regExp:

Expand|Select|Wrap|Line Numbers
  1. var re = /[.]/;
  2.  
matches in case there is any decimal-point in the string ... and you should check the value of your field ... not the field itself:

Expand|Select|Wrap|Line Numbers
  1. objField.value
kind regards
Apr 23 '08 #6

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

Similar topics

11
by: Maksim Kasimov | last post by:
in php-scripts, to insert data to database, i'm doing like this: ... $query_param = array( 'field0' => 1, 'field1' => 3, 'field2' => $var2, 'field3' => $var3, ); ...
3
by: David | last post by:
Hi, I am trying to put a very basic search function on a web page. I'm using access 2000 as the database, and have a memo field I want to search using a keyword entered via a form. The...
1
by: Mooky Mooksgill | last post by:
I would like to search a table for a phrase, or for a partial phrase, eg on table product - for name or description, or name + descprition. How does one say select * from product where name +...
11
by: Codemonkey | last post by:
Hi, I am writing an App in .Net that involves some scheduling of tasks. I was wondering if anybody has come accross any components or examples of how to implement a schedule manager like the one...
0
by: ron | last post by:
hi I am looking for a class that will give me the same functionality as the HttpContext that i can use in a Windows app Thanks Ron
6
by: Jonathan Wood | last post by:
If you're an experienced C#/ASP.NET developer looking for projects that you can do from your own location, I may be able to provide you with some work. For more info, please visit...
0
by: Borse, Ganesh | last post by:
Hi, Am new to python. May someone please help me know this? How can we check whether one big string contains another small string? E.g. bigstring="python anaconda boa cobra" smallone="boa"
8
by: SMJT | last post by:
Does anyone know why the string contains function always returns true if the token is an empty string? I expected it to return false. "AnyOldText".Contains("") or...
3
by: Bob Alston | last post by:
I am trying to access lotus notes documents. I am able to do this but the view in notes I have available contains multiple types of documents. I only want one of the types of documents. When i...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
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,...

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.