hi,
in my project...in one of the textbox...i need to take either numbersnumbers or NULL..im not getting any idea..can anyone help me out..here is my jsp code and js code.. login.jsp -
-
<td><font color="#800000" size=""><b>L-Acct. No.</b></font></td>
-
<td><input type="text" name="localAccNo" value=NULL></td>
-
login.js -
if (document.frm.localAccNo.value == "")
-
{
-
alert("Enter Local A/c No. or 'NULL' in capitals");
-
document.frm.localAccNo.focus();
-
return (false);
-
}
-
var chkLocalAccNo = "0123456789";
-
var chkLocalAccNoStr = document.frm.localAccNo.value;
-
var allchkLocalAccNoValid = true;
-
for (i = 0; i < chkLocalAccNoStr.length; i++)
-
{
-
ch = chkLocalAccNoStr.charAt(i);
-
for (j = 0; j < chkLocalAccNo.length; j++)
-
if (ch == chkLocalAccNo.charAt(j))
-
break;
-
if (j == chkLocalAccNo.length)
-
{
-
allchkLocalAccNoValid = false;
-
break;
-
}
-
}
-
if (!allchkLocalAccNoValid)
-
{
-
alert("Enter only numeric in the \" Local A/c No. \" field");
-
document.frm.localAccNo.focus();
-
return (false);
-
}
-
thanks,
madhu.
33 1604
I don’t understand your checking logic. you can test, whether an input qualifies for a number with either isFinite() or isNaN() (parseInt() would be a good starting point either, even RegExp were possible) and how to test for "NULL" I hopefully don’t have to explain.
hi,
i checked with the values..if i had given 'NULL' it is taking and if i give 'NULL123' is also taking...but i need is it should take either numbers or NULL that means L-Acct. No.----> NULL
or
L-Acct. No.----> 123
like this i need i used RegExp..eventhough im not getting can u suggest me how to do..
how familiar are you with RegExp?
i m not that much familiar..im a learner
i used like this -
-
if (document.frm.localAccNo.value == "")
-
{
-
alert("Enter Local A/c No. or 'NULL' in capitals");
-
document.frm.localAccNo.focus();
-
return (false);
-
}
-
var chkLocalAccNo = "[NULL/0123456] ";
-
var chkLocalAccNoStr = document.frm.localAccNo.value;
-
var allchkLocalAccNoValid = true;
-
for (i = 0; i < chkLocalAccNoStr.length; i++)
-
{
-
ch = chkLocalAccNoStr.charAt(i);
-
for (j = 0; j < chkLocalAccNo.length; j++)
-
if (ch == chkLocalAccNo.charAt(j))
-
break;
-
if (j == chkLocalAccNo.length)
-
{
-
allchkLocalAccNoValid = false;
-
break;
-
}
-
}
-
if (!allchkLocalAccNoValid)
-
{
-
alert("Enter only numeric in the \" Local A/c No. \" field");
-
document.frm.localAccNo.focus();
-
return (false);
-
}
-
no wonder that NULL123 worked …
ok, part one: how would you (in the simplest way) test for the string "NULL"?
-
if(document.frm.localAccNo.value == null){
-
alert(' null');
-
}else if(document.frm.localAccNo.value == 'null'){
-
alert('value is a string null');
-
}
-
-
looks good, but
- line 1/2 would also fire for "" (empty string).
- line 3/4 would not fire for "NULL" (or any version with capital letters)
tip: save the field’s value in a variable, that’s saving you (and the script) a massive amount of time.
i hope isNan() function should be used for this
isNan() would throw an error (because the function is called isNaN()), but it depends for what you need isNaN(). (as I already mentioned, isNaN() is one way to test a part of your requirements)
i didnt got ur point...can u help me how?
what will you use isNaN() for? there are codes, where isNaN() would definitely help, and codes where it were absolutely pointless.
hi,
gud mrng..i tried..its getting but the problem is if i enter 'NULL123' it is not showing error..can u suggest me where to change the code..here is my code..
login.js -
var chkLocalAccNo = document.frm.localAccNo.value;
-
//check if it is not a number
-
var validation = true;
-
for (var i = 0; i < chkLocalAccNo.length; i++ )
-
{
-
if (isNaN(chkLocalAccNo.charAt(i)))
-
{
-
//if it is not a number check if it is NULL
-
if (chkLocalAccNo == 'NULL')
-
{
-
validation = true;
-
document.frm.localAccNo.focus();
-
}
-
else
-
{
-
validation = false;
-
document.frm.localAccNo.focus();
-
}
-
}
-
}
-
-
thanx and waiting for the reply.
madhu.
i discard for loop eventhough it is not getting..
what does your code looks like now?
-
-
if (document.frm.localAccNo.value == "")
-
{
-
alert("Enter Local A/c No. or 'NULL' in capitals");
-
document.frm.localAccNo.focus();
-
return (false);
-
}
-
-
var chkLocalAccNo = document.frm.localAccNo.value;
-
//check if it is not a number
-
var validation = true;
-
if (isNaN(chkLocalAccNo.charAt(i)))
-
{
-
//if it is not a number check if it is NULL
-
if (chkLocalAccNo == 'NULL')
-
{
-
validation = true;
-
document.frm.localAccNo.focus();
-
}
-
else
-
{
-
validation = false;
-
document.frm.localAccNo.focus();
-
}
-
}
-
-
alert('Validation is: ' + validation);
-
-
if i give 'NULL' it is showing 'Valid' and going to another page same for nos. also..but if i give 'NULL123' it is showing 'Validation false' and it is going to another page by clicking submit button..but i should not get like that..
see line 12? esp. the charAt(i) portion?
i deleted and checked now same problem i m getting it is taking 'NULL123'...but not throwing error..
I can imagine why, but I’m not sure until I see the working code.
k,here is my code.. login.jsp -
<td></td>
-
<td><font color="#800000" size=""><b>L-Acct. No.</b></font></td>
-
<td><input type="text" name="localAccNo"></td>
-
<td></td>
-
login.js -
if (document.frm.localAccNo.value == "")
-
{
-
alert("Enter Local A/c No. or 'NULL' in capitals");
-
document.frm.localAccNo.focus();
-
return (false);
-
}
-
-
var chkLocalAccNo = document.frm.localAccNo.value;
-
//check if it is not a number
-
var validation = true;
-
if (isNaN(chkLocalAccNo))
-
{
-
//if it is not a number check if it is NULL
-
if (chkLocalAccNo == 'NULL')
-
{
-
validation = true;
-
document.frm.localAccNo.focus();
-
}
-
else
-
{
-
validation = false;
-
document.frm.localAccNo.focus();
-
}
-
}
-
-
alert('Validation is: ' + validation);
-
i need it urgent..where is wrong in the code..suggest me..
where is wrong in the code
it work for me.
i tried it is not getting...here is the code can u chk it. login.js -
function validate()
-
{
-
if (document.frm.multiAct.value == "")
-
{
-
alert("Enter Multiple Activation");
-
document.frm.multiAct.focus();
-
return (false);
-
}//Close of Multiple Activation Status
-
-
if (document.frm.nullDa.value == "")
-
{
-
alert("Enter Null DA");
-
document.frm.nullDa.focus();
-
return (false);
-
}//Close of Null DA Status
-
-
if (document.frm.localAccNo.value == "")
-
{
-
alert("Enter Local A/c No. or 'NULL' in capitals");
-
document.frm.localAccNo.focus();
-
return (false);
-
}
-
-
var chkLocalAccNo = document.frm.localAccNo.value;
-
//check if it is not a number
-
var validation = true;
-
if (isNaN(chkLocalAccNo))
-
{
-
//if it is not a number check if it is NULL
-
if (chkLocalAccNo == 'NULL')
-
{
-
validation = true;
-
document.frm.localAccNo.focus();
-
}
-
else
-
{
-
validation = false;
-
document.frm.localAccNo.focus();
-
}
-
}
-
-
alert('Validation is: ' + validation);
-
return true;
-
}
-
-
login.jsp -
-
<td></td>
-
<td><font color="#800000" size=""><b>Multiple Activation</b></font></td>
-
<td><input type="text" name="multiAct"></td>
-
<td></td>
-
<td><font color="#800000" size=""><b>Null DA</b></font></td>
-
<td><input type="text" name="nullDa"></td>
-
<td></td>
-
<td><font color="#800000" size=""><b>L-Acct. No.</b></font></td>
-
<td><input type="text" name="localAccNo"></td>
-
<td></td>
-
-
can u chk it..with the given code
post a link to the page, that makes it easier to check.
if I should test your script, I need it to test with your website, as it works when I build my own test page.
i m sorry i tried..but my ip address was blocked..i snded u the code u can chek it na
my ip address was blked by my cmpny..so i cant see my ip address..i hd pasted the code na...u cn chk it..
all you need is a personal webserver.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: lkrubner |
last post by:
What I need to do is find out what characters in a string are not
supported by the UTF-8 encoding. The problem arises when someone logs
in and uses my php script to create a weblog post. They are...
|
by: pesso |
last post by:
I have a string that contains the following:
string s = "130,41,43,178,41,17,6,78,244,35,202,144,115";
They are comma separated byte numbers, and I need to
initialize my byte array with them....
|
by: acool |
last post by:
I am passing in, as a parameter, a string of XML, and want to formulate a
new XML docuent but i am getting errors. I tried this:
public string makeDoc(string document)
{
//
XmlDocument doc =...
|
by: Alan Silver |
last post by:
Hello,
I am writing the code-behind for a user control that may have either a
Repeater or a DataList (depending on which .ascx file calls the
code-behind). I have put an DataItemBound event for...
|
by: Bryan |
last post by:
Apologies if this is a noob question, but I've been struggling with this for quite a while...
I'm trying to convert a byte array (encrypted authorization code) into a *screen-printable* string...
|
by: robert maas, see http://tinyurl.com/uh3t |
last post by:
I'm working on examples of programming in several languages, all
(except PHP) running under CGI so that I can show both the source
files and the actually running of the examples online. The first...
|
by: DR |
last post by:
how to determine what language a c# string is written in? is there any C#
method to take a string and return what language it is in? e.g. english,
hindi, spanish, etc.
|
by: DR |
last post by:
how to determine what language a string is written in? is there any method
to take a string and return what language it is in? e.g. english, hindi,
spanish, etc.
|
by: vrsoft |
last post by:
i want to separate string within the specified tag.
eg.,
<strong>some string here</strong>
result should be:"some string here"
pl help me.
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |