Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > page validation script - question

Reply
Thread Tools

page validation script - question

 
 
Raphael Gluck
Guest
Posts: n/a
 
      07-26-2004
HI

I am wondering if anyone can help me

I added a little script to a form page, so that a couple of fields have to
filled in. One contains an obligatory field for number data, one for regular
text.
However it seems that when a user will just enter a few spaces in the
required, they seem to be able to pass the validation script.

Here is the script, How should i modify it to exclude spaces?

Many thanks

Raphael

<script language="JavaScript" type="text/JavaScript">
<!--
function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_valida teForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2];
val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an
e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number
between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is
required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>


 
Reply With Quote
 
 
 
 
John
Guest
Posts: n/a
 
      07-26-2004
First of all: this is a ASP group.

Trim your field and if "" exit the function
Or if intr(field," ") 'two spaces' exit
Search the net for email validator scripts @ is not the only thing needed
for a valid script


 
Reply With Quote
 
 
 
 
Jeff Cochran
Guest
Posts: n/a
 
      07-26-2004
On Mon, 26 Jul 2004 11:40:45 +0100, "Raphael Gluck" <>
wrote:

>I am wondering if anyone can help me


Nope. This is an ASP forum, you're asking for help on a client-side
JavaScript script. Try a JavaScript forum.

Jeff

>I added a little script to a form page, so that a couple of fields have to
>filled in. One contains an obligatory field for number data, one for regular
>text.
>However it seems that when a user will just enter a few spaces in the
>required, they seem to be able to pass the validation script.
>
>Here is the script, How should i modify it to exclude spaces?
>
>Many thanks
>
>Raphael
>
><script language="JavaScript" type="text/JavaScript">
><!--
>function MM_validateForm() { //v4.0
> var i,p,q,nm,test,num,min,max,errors='',args=MM_valida teForm.arguments;
> for (i=0; i<(args.length-2); i+=3) { test=args[i+2];
>val=MM_findObj(args[i]);
> if (val) { nm=val.name; if ((val=val.value)!="") {
> if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
> if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an
>e-mail address.\n';
> } else if (test!='R') { num = parseFloat(val);
> if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
> if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
> min=test.substring(8,p); max=test.substring(p+1);
> if (num<min || max<num) errors+='- '+nm+' must contain a number
>between '+min+' and '+max+'.\n';
> } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is
>required.\n'; }
> } if (errors) alert('The following error(s) occurred:\n'+errors);
> document.MM_returnValue = (errors == '');
>}
>//-->
></script>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to execute a script from another script and other script does notdo busy wait. Rajat Python 3 01-08-2010 02:05 PM
RE: How to execute a script from another script and other script doesnotdo busy wait. VYAS ASHISH M-NTB837 Python 2 01-07-2010 08:18 PM
Page is not submitted using Client side validation of.NET validation Sudip ASP .Net Web Controls 0 07-01-2005 05:49 AM
Page appears to fail validation even though it has no validation controls =?Utf-8?B?ZGh1cndpdHo=?= ASP .Net 1 04-10-2004 07:37 AM
Passing value from one script on one page to another script on another page. Robert Cohen ASP General 3 07-15-2003 01:46 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57