fmwebschool.com
Top Experts [learn more]Top 4-10
webko

9743 K
bandmandq

2458 K
Genx

1525 K
4. tcmeyers
5. kbata
6. Martie
7. Hammerton
8. rrenfrow
9. bneeman
10. plegler
Welcome, Guest. Please login or register.
June 18, 2013, 03:51:14 PM

Login with username, password and session length
Search:     Advanced search
Welcome to the FileMaker Web Masters Exchange.  If you have any questions about how to use this forum, please watch the getting started movie at:
http://www.fmwebschool.com/movies/forum1/forum1.html
27507 Posts in 6073 Topics by 1524 Members
Latest Member: fmwebster
* Home Help Search Calendar Login Register
+  fmwebschool.com
|-+  PHP Web Publishing Technologies
| |-+  FileMaker PHP, FX.php custom web publishing
| | |-+  Force 7 Digits
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: Force 7 Digits  (Read 1679 times)
gbargsley
Hero Member
*****
Offline Offline

Posts: 172


« on: April 18, 2007, 07:10:44 AM »

Does anyone know of a script that will not allow a user to continue to the next page without a input text field having 7 numeric characters?  I am trying to force the user to enter the full ID number and every ID number is 7 digits.

Garry
Logged
FMWebschool
FMWebschool Team
Administrator
Hero Member
*****
Offline Offline

Posts: 1026
Kudos: 1383


Allyson Olm, Chief Developer


WWW
Applications:
« Reply #1 on: April 18, 2007, 08:04:03 AM »

Garry there are a couple ways you can do this,

Check this:

<input type="text" name="fullID" size="7" maxLength="7" >

and to force the id to be entered on submit use the form onSubmit event handler:

<form action="nextpage.htm" onSubmit="if(this.fullID.value.length!=7){alert('Enter ID');return false}" >


or you could put it into a function like this:


function formSubmit()
{
    if(this.fullID.value.length != 7)
    {
        alert('Enter ID');
        return false;
    }
    return true;
}
<form action="nextpage.htm" onSubmit="return formSubmit()">

In Kindness
Stephen Knight
« Last Edit: April 18, 2007, 08:13:39 AM by FMWebschool » Logged

In Kindness
FMWebschool Team
http://www.fmwebschool.com
http://www.fxforge.net
800.353.7950
gbargsley
Hero Member
*****
Offline Offline

Posts: 172


« Reply #2 on: April 18, 2007, 08:19:07 AM »

That looks good, however I have a question.

I already have an onsubmit (onSubmit="return checkrequired(this)") process to a javascript that makes sure two fields have a value.

How can I incorporate this in to my script below.


<SCRIPT LANGUAGE="JavaScript">
<!-- Original: wsabstract.com -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function checkrequired(which) {
var pass=true;
if (document.images) {
for (i=0;i<which.length;i++) {
var tempobj=which.elements;
if (tempobj.name.substring(0,8)=="required") {
if (((tempobj.type=="text"||tempobj.type=="textarea")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
break;
         }
      }
   }
}


if (!pass) {
shortFieldName=tempobj.name.substring(8,30).toUpperCase();
alert("Please make sure the "+shortFieldName+" field was properly completed.");
return false;
}
else
return formSubmit();
}
//  End -->

</script>

I edited your code, it should work now.

« Last Edit: April 18, 2007, 12:35:46 PM by FMWebschool » Logged
FMWebschool
FMWebschool Team
Administrator
Hero Member
*****
Offline Offline

Posts: 1026
Kudos: 1383


Allyson Olm, Chief Developer


WWW
Applications:
« Reply #3 on: April 18, 2007, 12:37:15 PM »

I edited your code at the bottom it said:

"else
return true;
}
// End -->"

I changed the code to:

return formSubmit();

which should do the trick

In Kindness
Stephen Knight

Logged

In Kindness
FMWebschool Team
http://www.fmwebschool.com
http://www.fxforge.net
800.353.7950
gbargsley
Hero Member
*****
Offline Offline

Posts: 172


« Reply #4 on: April 18, 2007, 01:01:26 PM »

Thanks for your help.  I put in the script as you edited and now it does not evern validate that the ID and/or School have a value.

* staff.php (3.7 KB - downloaded 53 times.)
Logged
Michael Petrov
Chief Software Developer
Administrator
Hero Member
*****
Offline Offline

Posts: 4286
Kudos: 15522




Applications:
« Reply #5 on: April 18, 2007, 02:31:10 PM »

Hi Garry,

You are missing the actual formSubmit function declaration, both functions have to be there but the formSubmit function will be called only after your existing validation code has been checked.

Best Regards,
Michael Petrov
Logged

Michael Petrov,
Chief Software Developer
FMWebschool
800.353.7950
michael@fmwebschool.com
Keep up with our development, follow me on Twitter
gbargsley
Hero Member
*****
Offline Offline

Posts: 172


« Reply #6 on: April 19, 2007, 05:31:30 AM »

Ok, I have the attached, and my empty validation work, but the checking for the length of ID is not working.

Any other suggestions?

Garry

* student.php (3.88 KB - downloaded 54 times.)
Logged
fmpdan
Jr. Member
**
Offline Offline

Posts: 96


Live One Day At A Time


« Reply #7 on: May 16, 2007, 01:47:13 PM »

If you are using Dreamweaver 9 then you can use the SPRY validation functions. If not you can get the files you need and docuemtnation from the adobe web site for free
http://labs.adobe.com/technologies/spry/

This is not in beta anymore. The \validation works great. It gets things validaed as the exit the field. Saves a ton of validation and JS code
Logged

'We create the world in which we live: if that world becomes unfit for human life, it is because we tire of our responsibility.'
Cyril Connolly 1938
Michael Petrov
Chief Software Developer
Administrator
Hero Member
*****
Offline Offline

Posts: 4286
Kudos: 15522




Applications:
« Reply #8 on: May 16, 2007, 01:54:16 PM »

I would like to second the Spry recommendation - all it takes is a few lines of javascript includes and then a single line for every field that you want to validate. The results are also visually impressive.

Best Regards,
Michael Petrov
Logged

Michael Petrov,
Chief Software Developer
FMWebschool
800.353.7950
michael@fmwebschool.com
Keep up with our development, follow me on Twitter
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!