Hi,
I am new to Javascript.I have Jsp file which contains form.I have done validation for date in javascript file.when field is blank i wants to set focus to textfiled.
so how can I access textfield in js file?
You should use a JS library.. You probably will need more functions in JS and the libraries will help you to do an easier work. Take a look: http://jquery.com/
see my JSP code:
<td colspan="5">
<html:text property="birthDay" onblur="daySize(this);"
maxlength="2"styleClass="datewidth" tabindex="15"/>
<span class="dashEnglish">
<bean:message key="common.slash"/>
</span>
</td>
I hav called daySize function on onblu.
n js code:
function daySize(target){
var length= target.value.length;
var flag=0;
if(target.value=="" || target.value=='' || target.value.charAt(0)==' ' || length==0){
alert("Please enter day value");
}
else if(length==1){
target.value="0"+target.value;
}
}
else{
alert("Day Should Be Integer");
flag=1;
}
}
if(flag==1){
// HERE I WANTS TO SET FOCUS TO TEXTFIELD