Hi, I am trying to add extra validation checks on an existing javascript code but I was hoping i can do this without changing the old codes. For example:
Old code:
$(".sendMessage").live("click", function( ) {
var subject = $.trim( $("#subject").val( ) );
if( subject == "" ) {
alert( "No subject added" );
return false;
}
return false;
});
Would like to add in/extend the sendMessage with extra check so as it becomes:
$(".sendMessage").live("click", function( ) {
var subject = $.trim( $("#subject").val( ) );
var content = $.trim( $("#textArea").val( ) );
if( subject == "" && content == "" ) { // new validation
alert( "No subject and content added" );
return false;
}
return false;
});
Is there a proper way to do this?