Hi,
this is my javascript validating the fields in mozilla FF but its working and validating only one field.
how to write the and how to works the script .................. -
function Test(){
-
-
-
alphaNumericInput(document.forms[0].dealerid);
-
-
digitsAlphabetsInput(document.forms[0].dealerid); //for digits only
-
alphabetsInput( document.forms[0].dealerid);//only alpha bets
-
-
}
-
-
function digitsInput(textField){
-
var regExp=/^[0-9]*$/;
-
if(textField.value=="" || regExp.test(textField.value))
-
return false;
-
-
alert("Only digits are allowed!");
-
textField.value = textField.value.replace(/[^0-9]/g,"");
-
}
-
function alphabetsInput(textField){
-
var regExp=/^[a-z A-Z]*$/;
-
if(textField.value=="" || regExp.test(textField.value))
-
return;
-
-
alert("Only alphabets symbols are allowed!");
-
textField.value = textField.value.replace(/[^a-z A-Z]/g,"");
-
}
-
var regExp=/^[0-9\a-z A-Z]*$/;
-
textField.value = textField.value.replace(/[^0-9\a-z A-Z]/g,"");
-
-
function digitsAlphabetsInput(textField){
-
var regExp=/^[0-9\a-z A-Z]*$/;
-
if(textField.value=="" || regExp.test(textField.value))
-
return;
-
-
alert("Only digits and alphabets are allowed!");
-
textField.value = textField.value.replace(/[^0-9\a-z A-Z]/g,"");
-
}
-
-
-
Thanks
ss.
16 1927
Heya, SS.
In test(), you're passing the same form element each time. Is this intentional?
-
function Test(){
-
-
-
alphaNumericInput(document.forms[0].dealerid);
-
-
alphabetsInput(document.forms[0].name);
-
alphabetsInput( document.forms[0].lname);
-
-
}
-
-
function digitsInput(textField){
-
var regExp=/^[0-9]*$/;
-
if(textField.value=="" || regExp.test(textField.value))
-
return false;
-
-
alert("Only digits are allowed!");
-
textField.value = textField.value.replace(/[^0-9]/g,"");
-
}
-
function alphabetsInput(textField){
-
var regExp=/^[a-z A-Z]*$/;
-
if(textField.value=="" || regExp.test(textField.value))
-
return;
-
-
alert("Only alphabets symbols are allowed!");
-
textField.value = textField.value.replace(/[^a-z A-Z]/g,"");
-
}
-
var regExp=/^[0-9\a-z A-Z]*$/;
-
textField.value = textField.value.replace(/[^0-9\a-z A-Z]/g,"");
-
-
function digitsAlphabetsInput(textField){
-
var regExp=/^[0-9\a-z A-Z]*$/;
-
if(textField.value=="" || regExp.test(textField.value))
-
return;
-
-
alert("Only digits and alphabets are allowed!");
-
textField.value = textField.value.replace(/[^0-9\a-z A-Z]/g,"");
-
}
-
-
i am passing differet values through the Body Onload. but it is checking only one first one. The above given is some of my sample code.
Heya, SS.
You did not declare a function named alphaNumericInput(). Did you mean digitsAlphabetsInput()?
gits 5,390
Expert Mod 4TB
hi ...
please have a close look at your script and the comments that i made within: -
function Test(){
-
// like pbmods said ... the following function is not declared
-
// and in your initial post all fields where 'dealerid' ...
-
alphaNumericInput(document.forms[0].dealerid);
-
-
alphabetsInput(document.forms[0].name);
-
alphabetsInput(document.forms[0].lname);
-
}
-
-
function digitsInput(textField){
-
var regExp=/^[0-9]*$/;
-
-
if(textField.value=="" || regExp.test(textField.value)) return false;
-
-
alert("Only digits are allowed!");
-
-
textField.value = textField.value.replace(/[^0-9]/g,"");
-
}
-
-
function alphabetsInput(textField){
-
var regExp=/^[a-z A-Z]*$/;
-
-
if(textField.value=="" || regExp.test(textField.value)) return;
-
-
alert("Only alphabets symbols are allowed!");
-
-
textField.value = textField.value.replace(/[^a-z A-Z]/g,"");
-
}
-
-
// the following two lines are useless i think ... they are executed
-
// during load and assign an regEx that is never used and
-
// should give an error since textField is undefined here
-
var regExp=/^[0-9\a-z A-Z]*$/;
-
-
textField.value = textField.value.replace(/[^0-9\a-z A-Z]/g,"");
-
-
function digitsAlphabetsInput(textField){
-
var regExp=/^[0-9\a-z A-Z]*$/;
-
-
if(textField.value=="" || regExp.test(textField.value)) return;
-
-
alert("Only digits and alphabets are allowed!");
-
-
textField.value = textField.value.replace(/[^0-9\a-z A-Z]/g,"");
-
}
-
fixing the function-name in the test-function should do the job. and a strict way to write down the code with strict indentation will help you a lot when searching matching brackets or useless lines of code ... delete them since they produce an error in our actual case ...
kind regards
hi ...
please have a close look at your script and the comments that i made within: -
function Test(){
-
alphaNumericInput(document.forms[0].dealerid);
-
-
alphabetsInput(document.forms[0].name);
-
alphabetsInput(document.forms[0].lname);
-
}
-
-
function digitsInput(textField){
-
var regExp=/^[0-9]*$/;
-
-
if(textField.value=="" || regExp.test(textField.value)) return false;
-
-
alert("Only digits are allowed!");
-
-
textField.value = textField.value.replace(/[^0-9]/g,"");
-
}
-
-
function alphabetsInput(textField){
-
var regExp=/^[a-z A-Z]*$/;
-
-
if(textField.value=="" || regExp.test(textField.value)) return;
-
-
alert("Only alphabets symbols are allowed!");
-
-
textField.value = textField.value.replace(/[^a-z A-Z]/g,"");
-
}
-
-
function digitsAlphabetsInput(textField){
-
var regExp=/^[0-9\a-z A-Z]*$/;
-
-
if(textField.value=="" || regExp.test(textField.value)) return;
-
-
alert("Only digits and alphabets are allowed!");
-
-
textField.value = textField.value.replace(/[^0-9\a-z A-Z]/g,"");
-
}
-
i removied that two lins also iam still geting same proble .now its not validating any field.
ss
gits 5,390
Expert Mod 4TB
;) you missed the first comment, and pbmods mentioned it too: - function Test(){
-
// there is no function called alphaNumericInput declared in your script
-
// you will get an error that alphaNumericInput is not a function
-
alphaNumericInput(document.forms[0].dealerid);
-
alphabetsInput(document.forms[0].name);
-
alphabetsInput(document.forms[0].lname);
-
}
declare that function or use the correct name of the function you want to use ...
kind regards
- function Test(){
-
digitsInput(document.forms[0].dealerid);
-
alphabetsInput(document.forms[0].name);
-
alphabetsInput(document.forms[0].lname);
-
}
iam using like this also not working do u know any validation script urls plz send that urls . ok
TQ
kind regards
gits 5,390
Expert Mod 4TB
... that's really confusing now, the following example works and uses all the code you provided ...
[HTML]<html>
<head>
<script>
function Test(){
digitsInput(document.forms[0].dealerid);
alphabetsInput(document.forms[0].name);
alphabetsInput( document.forms[0].lname);
}
function digitsInput(textField){
var regExp=/^[0-9]*$/;
if(textField.value=="" || regExp.test(textField.value))return false;
alert("Only digits are allowed!");
textField.value = textField.value.replace(/[^0-9]/g,"");
}
function alphabetsInput(textField){
var regExp=/^[a-z A-Z]*$/;
if(textField.value=="" || regExp.test(textField.value)) return;
alert("Only alphabets symbols are allowed!");
textField.value = textField.value.replace(/[^a-z A-Z]/g,"");
}
function digitsAlphabetsInput(textField){
var regExp=/^[0-9\a-z A-Z]*$/;
if(textField.value=="" || regExp.test(textField.value)) return;
alert("Only digits and alphabets are allowed!");
textField.value = textField.value.replace(/[^0-9\a-z A-Z]/g,"");
}
</script>
</head>
<body>
<form name="my_form">
<input type="text" name="dealerid"/>
<input type="text" name="name"/>
<input type="text" name="lname"/>
<input type="button" value="Validate" onclick="Test();"/>
</form>
</body>
</html>
[/HTML]
have a look at the firefox-javascript-console ... there has to be another error besides the one we found already ... how do you call Test();?
kind regards
gits 5,390
Expert Mod 4TB
... or another guess ... how should it work? may be it works for us but you want it to work another way? ...
hi
now iam using like this
iam getting this error in the console
Error: illegal character
Source File: http://ad.doubleclick.net/adj/ttm.thescripts/webdev/jsajax;cmy=webdev;zn=jsajax;sz=728x90;tile=1;ord=8 91731041?
Line: 1, Column: 6
Source Code:
GIF89a -
function Test(){
-
-
alert("doSubmit"+document.forms[0].dscpt.value);
-
-
-
digitsInput(document.forms[0].icno);
-
digitsInput(document.forms[0].id1);
-
alphabetsInput( document.forms[0].name);
-
digitsInput(document.forms[0].groupid);
-
}
-
-
function digitsInput(textField){
-
var regExp=/^[0-9]*$/;
-
if(textField.value=="" || regExp.test(textField.value))
-
return false;
-
-
alert("Only digits are allowed!");
-
textField.value = textField.value.replace(/[^0-9]/g,"");
-
}
-
function alphabetsInput(textField){
-
var regExp=/^[a-z A-Z]*$/;
-
if(textField.value=="" || regExp.test(textField.value))
-
return;
-
-
alert("Only alphabets symbols are allowed!");
-
textField.value = textField.value.replace(/[^a-z A-Z]/g,"");
-
}
-
-
-
function digitsAlphabetsInput(textField){
-
var regExp=/^[0-9\a-z A-Z]*$/;
-
if(textField.value=="" || regExp.test(textField.value))
-
return;
-
-
alert("Only digits and alphabets are allowed!");
-
textField.value = textField.value.replace(/[^0-9\a-z A-Z]/g,"");
-
}
-
-
-
-
Thanks gits.
hi
now iam using like this
iam getting this error in the console
Error: illegal character
Source File: http://ad.doubleclick.net/adj/ttm.th...ord=891731041?
Line: 1, Column: 6
Source Code:
GIF89a
if i click the error iam getting like this
GIF89a��€��ÿÿÿ���!ù����,�������D�;
and iam calling the function like this in the body
<body onload="Test()">
Thanks gits
gits 5,390
Expert Mod 4TB
heya shyamg,
is it working now or not? try the posted example and have a look whether you want this behaviour or not. if not ... then tell us what it is supposed to do.
do you get the alert you have now in your Test();-function? ... and again: when and how do you call this function? can you post more code? as we can see in the above example the lines we have are working ...
kind regards
gits 5,390
Expert Mod 4TB
hmmm ... we posted at the same time ...
you validate the form onload? do you expect wrong entrys at this time? are the values prefilled in any way?
but thats not our original problem ;) ... is the example working for you? in that case your script should work too except of other errors that we may find when you post some more code ...
kind regards
hi
u replied something abt converting dbf files to postgres could you please be specific .i'm a beginner please help me.
gits 5,390
Expert Mod 4TB
hi
u replied something abt converting dbf files to postgres could you please be specific .i'm a beginner please help me.
Hi ...
please post a specific question in the PostgreSQL-Forum ... the experts over there will be glad to help you with your problems
kind regards
Heya, shyamg.
hi
now iam using like this
iam getting this error in the console
Error: illegal character
Source File: http://ad.doubleclick.net/adj/ttm.thescripts/webdev/jsajax;cmy=webdev;zn=jsajax;sz=728x90;tile=1;ord=8 91731041?
Line: 1, Column: 6
Source Code:
GIF89a
Are you including any advertising or tracking JavaScript in your page?
Try running a Spyware search. Your computer may be infected.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Kevin Lyons |
last post by:
Hello,
I am trying to get my select options (courses) passed correctly from
the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html
I am having difficulty getting the...
|
by: lawrence |
last post by:
This PHP function prints out a bunch of Javascript (as you can see).
This is all part of the open source weblog software of PDS
(www.publicdomainsoftware.org). We had this javascript stuff...
|
by: VictorG |
last post by:
Hello,
I am new to JS and am trying to add some HTML into a JS function. So
that when called the script as well as the HTML will be invoked. Is
there some type of embed mechanism, sort of the...
|
by: chrisdude911 |
last post by:
how do i add video into a javascript web page with my own custom
buttons?
|
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: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
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: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
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...
| |