what is wrong in my below code , it gives error that document.forms[0].fieldfocues is undefined.
function inputvalidation(){
if(document.forms[0].client_x.value==“” ){
alert(“Please enter Client Name”)
document.forms[0].client_x.focus()
document.forms[0].fieldfocus.value = “client_x”
return false;
}
Subject: problem in java script validation
Are you sure that the case of your field is written correctly ?
Don’t forget Javascript is case sensitive !
Renaud
Subject: RE: problem in java script validation
hi, i have given correct field name and also in correct sensitive.couldn’t find out the solution.
regds
Subject: RE: problem in java script validation
Is it possible to have the whole source of the webpage ?
Renaud
Subject: problem in java script validation
Do you have a field on the form called “fieldfocus”? There’s no fieldfocus property of a .
Subject: problem in java script validation
Hope this helps you
if( document.forms[0].client_x.value == ‘’ ){
alert( ‘Please enter Client Name’ );
document.forms[0].client_x.value = ‘client_x’;
document.forms[0].client_x.focus();
document.forms[0].client_x.select();
return false;
}
Subject: RE: problem in java script validation
hi, ur code not giving any error but return false open another window and print false. i am having lot of field validation, if i remove return false all the validation r prompting continuesly.
regds
soma
Subject: RE: problem in java script validation
Why using JS for this and not formula?
@If( client_x = “”; @Failure(“Please enter Client Name”); @Success)
I also think in your JS code you have to return for sure a value and not just in case of a failure.
if( document.forms[0].client_x.value == ‘’ ){
alert( ‘Please enter Client Name’ );
document.forms[0].client_x.value = ‘client_x’;
document.forms[0].client_x.focus();
document.forms[0].client_x.select();
return false;
}
else return true;
Hope this works now
Subject: RE: problem in java script validation
hi, i want to use javascript only if i use formula it will prompt message in another another window.
in ur javascript, the return false opening another window and printing false. it is strange , i am using IE 6.0 .
regds
soma
Subject: RE: problem in java script validation
Here is teh code of a HTML page with JS like I do validation on the web. Hope this helps
<TITLE>Validation test</TITLE>
<STYLE>
.def { font-size: 12px; font-weight: 500; font-style: normal; color: #000000; font-family: Arial;}
.defBold { font-size: 12px; font-weight: 900; font-style: normal; color: #000000; font-family: Arial;}
.empty { font-size: 5px; font-weight: 500; font-style: normal; color: #000000; font-family: Arial;}
.button { font-size: 12px; font-weight: 500; font-style: normal; color: #000000; font-family: Arial; background-color: #D7D7EB}
</STYLE>
<SCRIPT><!--
function validate(ref){
var status = true
if ( status && (( ref == 'field1') || (ref == '')) ) status = validateF1()
if ( status && (( ref == 'field2') || (ref == '')) ) status = validateF2()
if ( status && (( ref == 'client_x') || (ref == '')) ) status = validateClient_X()
if ( status && (( ref == 'fieldn') || (ref == '')) ) status = validateFn()
return status
}
// specific validation for field client_x
function validateClient_X(){
var status = true
var ele = document.getElementById('client_x')
if (ele.value == ''){
status = false
alert('Please enter a name')
}
return status
}
// specific validation for field1
function validateF1(){
var status = true
var ele = document.getElementById('field1')
if (ele.value == ''){
status = false
alert('Field 1 is empty')
}
return status
}
// specific validation for field2
function validateF2(){
var status = true
var ele = document.getElementById('field2')
if (ele.value == ''){
status = false
alert('Field 2 is empty')
}
return status
}
// specific validation for fieldn
function validateFn(){
var status = true
var ele = document.getElementById('fieldn')
if (ele.value == ''){
status = false
alert('Field n is empty')
}
return status
}
function doSubmit(){
if ( validate('') ){
// do what you want after success full validation
alert('Validation passed')
submit()
}
else{
// do some action here if you still need
alert('Validation failed')
}
}
-->
</SCRIPT>
<TABLE align="center" border="0" cellspacing="0" bgcolor="#E6E6F0">
<TR class="empty">
<TD rowspan="10" width="15"> </TD>
<TD class="empty" colspan="3"> </TD>
<TD class="empty" colspan="3" bgcolor="#D7D7EB"> </TD>
</TR>
<TR class="defBold">
<TD colspan="2">Field validation</TD>
<TD rowspan="9" width="25"> </TD>
<TD rowspan="9" width="10" bgColor="#888888"> </TD>
</TR>
<TR class="def">
<TD width="100">Field 1 test</TD>
<TD width="100"><INPUT name="field1" type="text" id="field1" value="" onBlur="validate('field1')"></TD>
</TR>
<TR class="def">
<TD width="100">Field 2 test</TD>
<TD width="100"><INPUT name="field2" type="text" id="field2" value="" onBlur="validate('field2')"></TD>
</TR>
<TR class="def">
<TD width="100">Client_x</TD>
<TD width="100"><INPUT name="client_x" type="text" id="client_x" value="" onBlur="validate('client_x')"></TD>
</TR>
<TR class="def">
<TD width="100">Field n test</TD>
<TD width="100"><INPUT name="fieldn" type="text" id="fieldn" value="" onBlur="validate('fieldn')"></TD>
</TR>
<TR class="empty">
<TD colspan="2"> </TD>
</TR>
<TR>
<TD align="center" colspan="2"><INPUT class="button" type="submit" value="Submit" onClick="doSubmit()">
<TR>
<TR class="empty">
<TD colspan="2"> </TD>
</TR>
<TR class="empty">
<TD bgColor="#D7D7EB"> </TD>
<TD colspan="4" bgColor="#888888"> </TD>
</TR>
</TABLE>