now i am using javascript to do a "flexiable" validaion, what i mean "flexiable" is user can choose which one they would like fill in in the bank but at least they must enter one.
in my page, i offered three kind of phone NO to let user enter in, one is Home phone NO, the other is Hand phone NO, the last one is Office Pone No. they can enter in "one or More" of these phone NO.
however my validation have problem and i cant probably check the correctness of their phone no.
the following is my current javascript
Expand|Select|Wrap|Line Numbers
- :
- <script language="JavaScript">
- <!--
- function validate_form ( )
- {
- valid = true;
- if ( document.regForm.uName.value == "" )
- {
- alert ( "Please fill in the 'Your name' box." );
- regForm.uName.focus();
- valid = false;
- }
- else if ( ( document.regForm.Hphone.value=="" )
- && ( document.regForm.HP.value =="") && ( document.regForm.Ophone.value == "") )
- {
- alert ( "Please enter any one of the three phone NO" );
- valid = false;
- if ( ((/^(\((\+\d{2})?\))?[56]\d{7}$/).test(regForm.Hphone.value) ==true)){
- alert ( "the Home phone No entered is not valid" );
- valid = true;
- }
- else if (((/^(\((\+\d{2})?\))?[89]\d{7}$/).test(regForm.HP.value) ==true)){
- alert ( "the HP phone No entered is not valid" );
- valid = true;
- }
- else if (((/^(\((\+\d{2})?\))?[3456]\d{7}$/).test(regForm.Ophone.value) ==true)){
- alert ( "the Office phone No entered is not valid" );
- valid = true;
- }
- }
- return valid;
- }
- //-->
- </script>