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!
<html><head><title>Add a Command</title>
<script language="JavaScript">
function validate() {
if (document.addcmd.[B]commandID[/B].value.length < 1) {
alert('You must enter a Command Word');
return false;
}
if (document.addcmd.[B]commandID[/B].value.length < 5) {
alert('Sorry, The Command Word must be at least 5 characters long');
return false;
}
if (document.addcmd.[B]commandID[/B].value.length > 10) {
alert('Sorry, The Command Word must be less than 10 characters long');
return false;
}
if (!(document.addcmd.[B]commandID[/B].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) [B]commandID[/B] must contain words " ON" or " OFF" (with a space before them hence " OFF")
//[Devices]
//2) [B]x10_channel[/B] must follow format of: A01 (a letter from A-Z followed by two numbers between 01 and 99) EEK!
//[Users]
//3) [B]number [/B] must be NUMERIC but allow the character "+"
//[View]
//4) [B]delboy[][/B] must be CHECKED
//ACTUAL CHECKBOX INPUT BELOW FOR CLARIFICATION:
//<input type="checkbox" name="delboy[]" value="' . $device . '" />
if (document.addcmd.[B]x10_channel[/B].value == "") {
alert('You must select an X10 Channel from the drop down box');
return false;
}
if (document.addcmd.[B]x10_command[/B].value == "") {
alert('You must select an X10 Command value from the drop down box');
return false;
}
else {
return true;
}
}
</script>