To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > Misc Help > ClientSide Technologies

ClientSide Technologies Discuss HTML/CSS/Javascript, and any other client-side technologies, here.

Reply
 
Thread Tools Rate Thread Display Modes
Old 03-30-2006, 11:48 AM   #1
The MA
Member
 
Join Date: Feb 2006
Posts: 40
Talking JS Validation in PHP - 4 Points

This is really a JS post - I'm adding validation to my PHP script but have stumbled on 4 points. The Code is below and the 4 points that I want to add but haven't been able to are commented below in the code. Some points are trickier than others. Many many thanks in advance to those who help even if you only help with 1 out of the 4!

Code:
<html><head><title>Add a Command</title>

<script language="JavaScript">

function validate() {

if (document.addcmd.commandID.value.length < 1) {
alert('You must enter a Command Word');
return false;
}
if (document.addcmd.commandID.value.length < 5) {
alert('Sorry, The Command Word must be at least 5 characters long');
return false;
}
if (document.addcmd.commandID.value.length > 10) {
alert('Sorry, The Command Word must be less than 10 characters long');
return false;
}
if (!(document.addcmd.commandID.value.match(/^[a-zA-Z0-9]+$/))) {
alert('Sorry, The Command Word must contain letters and numbers only');
return false;
}


// THE FOLLOWING ARE THE FOUR VALIDATION POINTS I AM UNCLEAR about:

//[For This Page]

//1) commandID must contain words " ON" or " OFF" (with a space before them hence " OFF")

//[Devices]

//2) x10_channel must follow format of: A01 (a letter from A-Z followed by two numbers between 01 and 99) EEK!

//[Users]

//3) number  must be NUMERIC but allow the character "+" 

//[View]

//4) delboy[] must be CHECKED
//ACTUAL CHECKBOX INPUT BELOW FOR CLARIFICATION:
//<input type="checkbox" name="delboy[]" value="' . $device . '" />                            

if (document.addcmd.x10_channel.value == "")  {
alert('You must select an X10 Channel from the drop down box');
return false;
}
if (document.addcmd.x10_command.value == "") {
alert('You must select an X10 Command value from the drop down box');
return false;
}

else {
return true;
}
}
</script>
The MA is offline   Reply With Quote
Old 03-30-2006, 02:11 PM   #2
The MA
Member
 
Join Date: Feb 2006
Posts: 40
Well I've worked out the 3rd one thanks.... could ANYONE please help :\
The MA is offline   Reply With Quote
Old 03-30-2006, 03:43 PM   #3
The MA
Member
 
Join Date: Feb 2006
Posts: 40
Come on guys I've solved two of them on my own now after hours of trying (i'm so noob ) PLEASE help me with these last two I actually CAN'T do them:

commandID must contain words " ON" or " OFF" (with a space before them hence " OFF")

delboy[] must be CHECKED

This is the PHP line of code in the form for the check box:
PHP Code:
<input type="checkbox" name="delboy[]" value="' . $device . '" />
The MA is offline   Reply With Quote
Old 03-30-2006, 04:32 PM   #4
The MA
Member
 
Join Date: Feb 2006
Posts: 40
http://forums.devshed.com/javascript...ml#post1446948

For full thread and scripts if you have time to help Thanks so much
The MA is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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
Forum Jump


All times are GMT -4. The time now is 11:50 AM.






Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.